/** * {@inheritDoc} */ public function process(ContainerBuilder $builder) { $ids = $builder->findTaggedServiceIds('console.command'); $console = $builder->getDefinition('console.application'); foreach ($ids as $id => $tags) { $command = $builder->getDefinition($id); if ($command->isAbstract()) { throw Exception::commandIsAbstract($id); } if (!$command->isPublic()) { throw Exception::commandIsNotPublic($id); } $reflect = new ReflectionClass($command->getClass()); if (!$reflect->isSubclassOf('Symfony\\Component\\Console\\Command\\Command')) { throw Exception::commandIsNotCommand($id); } $console->addMethodCall('add', array(new Reference($id))); } }