2010-02-17 13:54:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Symfony\Foundation\Bundle;
|
|
|
|
|
|
|
|
use Symfony\Components\DependencyInjection\ContainerInterface;
|
2010-04-12 20:56:42 +01:00
|
|
|
use Symfony\Components\Console\Application;
|
2010-02-17 13:54:36 +00:00
|
|
|
|
|
|
|
/*
|
2010-04-07 01:51:29 +01:00
|
|
|
* This file is part of the Symfony framework.
|
2010-02-17 13:54:36 +00:00
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-07 01:51:29 +01:00
|
|
|
* Bundle.
|
2010-02-17 13:54:36 +00:00
|
|
|
*
|
2010-04-07 01:51:29 +01:00
|
|
|
* @package Symfony
|
|
|
|
* @subpackage Foundation
|
2010-02-17 13:54:36 +00:00
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*/
|
|
|
|
abstract class Bundle implements BundleInterface
|
|
|
|
{
|
|
|
|
public function buildContainer(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function boot(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
}
|
2010-04-19 08:05:11 +01:00
|
|
|
|
|
|
|
public function shutdown(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
}
|
2010-04-12 20:56:42 +01:00
|
|
|
|
|
|
|
public function registerCommands(Application $application)
|
|
|
|
{
|
|
|
|
foreach ($application->getKernel()->getBundleDirs() as $dir)
|
|
|
|
{
|
|
|
|
$bundleBase = dirname(str_replace('\\', '/', get_class($this)));
|
|
|
|
$commandDir = $dir.'/'.basename($bundleBase).'/Command';
|
|
|
|
if (!is_dir($commandDir))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// look for commands
|
|
|
|
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($commandDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file)
|
|
|
|
{
|
|
|
|
if ($file->isDir() || substr($file, -4) !== '.php')
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$class = str_replace('/', '\\', $bundleBase).'\\Command\\'.str_replace(realpath($commandDir).'/', '', basename(realpath($file), '.php'));
|
|
|
|
|
|
|
|
$r = new \ReflectionClass($class);
|
|
|
|
|
|
|
|
if ($r->isSubclassOf('Symfony\\Components\\Console\\Command\\Command') && !$r->isAbstract())
|
|
|
|
{
|
|
|
|
$application->addCommand(new $class());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-17 13:54:36 +00:00
|
|
|
}
|