Example #1
0
 /**
  * {@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)));
     }
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $builder)
 {
     $ids = $builder->findTaggedServiceIds('console.helper');
     $helperSet = $builder->getDefinition('console.helper_set');
     foreach ($ids as $id => $tags) {
         $helper = $builder->getDefinition($id);
         if ($helper->isAbstract()) {
             throw Exception::helperIsAbstract($id);
         }
         if (!$helper->isPublic()) {
             throw Exception::helperIsNotPublic($id);
         }
         $reflect = new ReflectionClass($helper->getClass());
         if (!$reflect->isSubclassOf('Symfony\\Component\\Console\\Helper\\Helper')) {
             throw Exception::helperIsNotHelper($id);
         }
         foreach ($tags as $tag) {
             $helperSet->addMethodCall('set', array(new Reference($id), isset($tag['alias']) ? $tag['alias'] : null));
         }
     }
 }
Example #3
0
 /**
  * Registers the tagged event subscribers.
  *
  * @param ContainerBuilder $builder    The service container builder.
  * @param Definition       $dispatcher The event dispatcher definition.
  *
  * @throws Exception If the subscriber could not be registered.
  */
 private function registerSubscribers(ContainerBuilder $builder, Definition $dispatcher)
 {
     $ids = $builder->findTaggedServiceIds('event.subscriber');
     foreach ($ids as $id => $tags) {
         $subscriber = $builder->getDefinition($id);
         if ($subscriber->isAbstract()) {
             throw Exception::subscriberIsAbstract($id);
         }
         if (!$subscriber->isPublic()) {
             throw Exception::subscriberIsNotPublic($id);
         }
         $reflect = new ReflectionClass($subscriber->getClass());
         if (!$reflect->implementsInterface('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface')) {
             throw Exception::subscriberIsNotSubscriber($id);
         }
         $dispatcher->addMethodCall('addSubscriber', array(new Reference($id)));
     }
 }