@@ -31,21 +31,26 @@ public function getEnabledResources()
31
31
{
32
32
$ apiResources = array ();
33
33
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 ];
38
40
}
39
41
}
40
42
41
43
$ modulesHaveApi = Zend_Registry::get ('modulesHaveApi ' );
42
44
$ enabledModules = Zend_Registry::get ('modulesEnable ' );
43
45
$ apiModules = array_intersect ($ modulesHaveApi , $ enabledModules );
46
+
44
47
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 ];
49
54
}
50
55
}
51
56
}
@@ -147,7 +152,7 @@ public function getResourceApiDocs($resource, $module = '')
147
152
'name ' => 'useSession ' ,
148
153
'paramType ' => 'query ' ,
149
154
'required ' => false ,
150
- 'description ' => 'Authenticate using the current Midas session ' ,
155
+ 'description ' => 'Authenticate using the current session ' ,
151
156
'allowMultiple ' => false ,
152
157
'dataType ' => 'string ' ,
153
158
);
0 commit comments