@@ -31,21 +31,26 @@ public function getEnabledResources()
3131 {
3232 $ apiResources = array ();
3333
34- foreach (glob (BASE_PATH .'/core/controllers/components/Api*.php ' ) as $ filename ) {
35- $ resoucename = preg_replace ('/Component\.php/ ' , '' , substr (basename ($ filename ), 3 ));
36- if (!in_array ($ resoucename , array ('helper ' , 'docs ' ))) {
37- $ apiResources [] = '/ ' .$ resoucename ;
34+ $ directory = new DirectoryIterator (BASE_PATH .'/core/controllers/components ' );
35+ $ matches = new RegexIterator ($ directory , '#Api(.*)Component\.php$# ' , RegexIterator::GET_MATCH );
36+
37+ foreach ($ matches as $ match ) {
38+ if (!in_array ($ match [1 ], array ('helper ' , 'docs ' ))) {
39+ $ apiResources [] = '/ ' .$ match [1 ];
3840 }
3941 }
4042
4143 $ modulesHaveApi = Zend_Registry::get ('modulesHaveApi ' );
4244 $ enabledModules = Zend_Registry::get ('modulesEnable ' );
4345 $ apiModules = array_intersect ($ modulesHaveApi , $ enabledModules );
46+
4447 foreach ($ apiModules as $ apiModule ) {
45- foreach (glob (BASE_PATH .'/modules/ ' .$ apiModule .'/controllers/components/Api*.php ' ) as $ filename ) {
46- $ resourceName = preg_replace ('/Component\.php/ ' , '' , substr (basename ($ filename ), 3 ));
47- if (!in_array ($ resourceName , array ('' ))) {
48- $ apiResources [] = $ apiModule .'/ ' .$ resourceName ;
48+ $ directory = new DirectoryIterator (BASE_PATH .'/modules/ ' .$ apiModule .'/controllers/components ' );
49+ $ matches = new RegexIterator ($ directory , '#Api(.*)Component\.php$# ' , RegexIterator::GET_MATCH );
50+
51+ foreach ($ matches as $ match ) {
52+ if (!in_array ($ match [1 ], array ('' ))) {
53+ $ apiResources [] = $ apiModule .'/ ' .$ match [1 ];
4954 }
5055 }
5156 }
@@ -147,7 +152,7 @@ public function getResourceApiDocs($resource, $module = '')
147152 'name ' => 'useSession ' ,
148153 'paramType ' => 'query ' ,
149154 'required ' => false ,
150- 'description ' => 'Authenticate using the current Midas session ' ,
155+ 'description ' => 'Authenticate using the current session ' ,
151156 'allowMultiple ' => false ,
152157 'dataType ' => 'string ' ,
153158 );
0 commit comments