PPI\Framework\Module\AbstractModule::registerCommands PHP Метод

registerCommands() публичный Метод

Override this method if your module commands do not follow the conventions: * Commands are in the 'Command' sub-directory * Commands extend PPI\Framework\Console\Command\AbstractCommand
public registerCommands ( PPI\Framework\Console\Application $application )
$application PPI\Framework\Console\Application An Application instance
    public function registerCommands(Application $application)
    {
        if (!is_dir($dir = $this->getCommandsPath())) {
            return;
        }
        $finder = new Finder();
        $finder->files()->name('*Command.php')->in($dir);
        $prefix = $this->getNamespace() . '\\Command';
        foreach ($finder as $file) {
            $ns = $prefix;
            if ($relativePath = $file->getRelativePath()) {
                $ns .= '\\' . strtr($relativePath, '/', '\\');
            }
            $r = new \ReflectionClass($ns . '\\' . $file->getBasename('.php'));
            if ($r->isSubclassOf('PPI\\Framework\\Console\\Command\\AbstractCommand') && !$r->isAbstract()) {
                $application->add($r->newInstance());
            }
        }
    }