public function defaultAction() { $this->writeln('Available commands:'); $controllers = array('SolveConsole\\Controllers\\DbController', 'SolveConsole\\Controllers\\GenController'); $commandsList = ''; foreach ($controllers as $controllerName) { $r = new \ReflectionClass($controllerName); $name = Inflector::underscore(substr($r->getShortName(), 0, -10)); $help = DocComment::parseFromString($r->getDocComment())->getAnnotationsAsString('help'); $commandsList .= ' <bold>' . $name . "</bold>\t" . $help . "\n"; } $this->writeln($commandsList); }
public function defaultAction() { $methods = $this->_reflect->getMethods(\ReflectionMethod::IS_PUBLIC); $methodsList = ''; $skippedMethods = array('_preAction', '_postAction', 'defaultAction'); foreach ($methods as $method) { if (!in_array($method->getName(), $skippedMethods) && substr($method->getName(), -6) === 'Action') { $commandMethod = str_replace('_', '-', Inflector::underscore(substr($method->getName(), 0, -6))); $doc = DocComment::parseFromString($method->getDocComment()); $optional = $doc->getAnnotationsAsString('optional'); $methodsList .= " <bold>" . $commandMethod . (strlen($commandMethod) < 16 ? str_repeat(' ', 12 - strlen($commandMethod)) : '') . "\t</bold>" . $doc->getDescription() . ($optional ? "\n\t\t" . $optional : "") . "\n"; } } if (!empty($methodsList)) { $this->writeln('Here are methods of ' . $this->_command . ":"); $this->writeln($methodsList); } else { $this->writeln('Command ' . $this->_commandColor . ' does not have any methods'); } }