private function createHelp()
{
$scannedTasksDir = array_diff(scandir($this->tasksDir), ['..', '.']);
$config = $this->getDI()->get('config');
$dispatcher = $this->getDI()->getShared('dispatcher');
$namespace = $dispatcher->getNamespaceName();
if (isset($config['annotationsAdapter']) && $config['annotationsAdapter']) {
$adapter = '\\Phalcon\\Annotations\\Adapter\\' . $config['annotationsAdapter'];
if (class_exists($adapter)) {
$reader = new $adapter();
} else {
$reader = new MemoryAdapter();
}
} else {
$reader = new MemoryAdapter();
}
foreach ($scannedTasksDir as $taskFile) {
$taskFileInfo = pathinfo($taskFile);
$taskClass = ($namespace ? $namespace . '\\' : '') . $taskFileInfo["filename"];
$taskName = strtolower(str_replace('Task', '', $taskFileInfo["filename"]));
$this->documentation[$taskName] = ['description' => [''], 'actions' => []];
$reflector = $reader->get($taskClass);
$annotations = $reflector->getClassAnnotations();
if (!$annotations) {
continue;
}
// Class Annotations
foreach ($annotations as $annotation) {
if ($annotation->getName() == 'description') {
$this->documentation[$taskName]['description'] = $annotation->getArguments();
}
}
$methodAnnotations = $reflector->getMethodsAnnotations();
// Method Annotations
if (!$methodAnnotations) {
continue;
}
foreach ($methodAnnotations as $action => $collection) {
if ($collection->has('DoNotCover')) {
continue;
}
$actionName = strtolower(str_replace('Action', '', $action));
$this->documentation[$taskName]['actions'][$actionName] = [];
$actionAnnotations = $collection->getAnnotations();
foreach ($actionAnnotations as $actAnnotation) {
$_anotation = $actAnnotation->getName();
if ($_anotation == 'description') {
$getDesc = $actAnnotation->getArguments();
$this->documentation[$taskName]['actions'][$actionName]['description'] = $getDesc;
} elseif ($_anotation == 'param') {
$getParams = $actAnnotation->getArguments();
$this->documentation[$taskName]['actions'][$actionName]['params'][] = $getParams;
}
}
}
}
}