protected function _loadPlugins()
{
$autoloader = $this->_plugin_path . '/vendor/autoload.php';
if (file_exists($autoloader)) {
require_once $autoloader;
}
$plugins = $this->getPlugins();
$classes = array();
foreach ($plugins as $package => $version) {
$path = $this->_plugin_path . '/vendor/' . $package;
$directories = glob($path . '/*/Console/Command', GLOB_ONLYDIR);
foreach ($directories as $directory) {
$vendor = substr($directory, strlen($path) + 1, strlen('/Console/Command') * -1);
$iterator = new \DirectoryIterator($directory);
foreach ($iterator as $file) {
if ($file->getExtension() == 'php') {
$classes[] = sprintf('%s\\Console\\Command\\%s', $vendor, $file->getBasename('.php'));
}
}
}
}
foreach ($classes as $class) {
if (class_exists($class)) {
$command = new $class();
if (!$command instanceof \Symfony\Component\Console\Command\Command) {
continue;
}
$name = $command->getName();
if (!$this->has($name)) {
$this->add($command);
} else {
$this->_output->writeln("<fg=yellow;options=bold>Notice:</fg=yellow;options=bold> The '{$class}' command wants to register the '{$name}' command but it already exists, ignoring.");
}
}
}
}