instantiate valid commands only
This commit is contained in:
parent
bc1bf3202d
commit
afad9c7894
@ -189,7 +189,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
|
||||
$ns .= '\\'.strtr($relativePath, '/', '\\');
|
||||
}
|
||||
$r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php'));
|
||||
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
|
||||
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
|
||||
$application->add($r->newInstance());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/**
|
||||
* This command has a required parameter on the constructor and will be ignored by the default Bundle implementation.
|
||||
*
|
||||
* @see Symfony\Component\HttpKernel\Bundle\Bundle::registerCommands
|
||||
*/
|
||||
class BarCommand extends Command
|
||||
{
|
||||
public function __construct($example, $name = 'bar')
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user