Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Replace use of glob in API docs since it not available on App Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Dec 12, 2014
1 parent a4c1a86 commit 5377088
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/controllers/ApidocsController.php
Expand Up @@ -49,7 +49,7 @@ public function indexAction()
}
$curResource = array();
$curResource['path'] = $resourcePath;
$curResource['discription'] = 'Operations about '.$resourcePath;
$curResource['description'] = 'Operations on the '.$resourcePath.' resource';
array_push($results['apis'], $curResource);
}
echo JsonComponent::encode($results);
Expand Down
23 changes: 14 additions & 9 deletions core/controllers/components/ApidocsComponent.php
Expand Up @@ -31,21 +31,26 @@ public function getEnabledResources()
{
$apiResources = array();

foreach (glob(BASE_PATH.'/core/controllers/components/Api*.php') as $filename) {
$resoucename = preg_replace('/Component\.php/', '', substr(basename($filename), 3));
if (!in_array($resoucename, array('helper', 'docs'))) {
$apiResources[] = '/'.$resoucename;
$directory = new DirectoryIterator(BASE_PATH.'/core/controllers/components');
$matches = new RegexIterator($directory, '#Api(.*)Component\.php$#', RegexIterator::GET_MATCH);

foreach ($matches as $match) {
if (!in_array($match[1], array('helper', 'docs'))) {
$apiResources[] = '/'.$match[1];
}
}

$modulesHaveApi = Zend_Registry::get('modulesHaveApi');
$enabledModules = Zend_Registry::get('modulesEnable');
$apiModules = array_intersect($modulesHaveApi, $enabledModules);

foreach ($apiModules as $apiModule) {
foreach (glob(BASE_PATH.'/modules/'.$apiModule.'/controllers/components/Api*.php') as $filename) {
$resourceName = preg_replace('/Component\.php/', '', substr(basename($filename), 3));
if (!in_array($resourceName, array(''))) {
$apiResources[] = $apiModule.'/'.$resourceName;
$directory = new DirectoryIterator(BASE_PATH.'/modules/'.$apiModule.'/controllers/components');
$matches = new RegexIterator($directory, '#Api(.*)Component\.php$#', RegexIterator::GET_MATCH);

foreach ($matches as $match) {
if (!in_array($match[1], array(''))) {
$apiResources[] = $apiModule.'/'.$match[1];
}
}
}
Expand Down Expand Up @@ -147,7 +152,7 @@ public function getResourceApiDocs($resource, $module = '')
'name' => 'useSession',
'paramType' => 'query',
'required' => false,
'description' => 'Authenticate using the current Midas session',
'description' => 'Authenticate using the current session',
'allowMultiple' => false,
'dataType' => 'string',
);
Expand Down

0 comments on commit 5377088

Please sign in to comment.