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());
}
}
}