Пример #1
0
 /**
  * Loads ids for services tagged as constraint validators.
  *
  * @param TaggedContainerInterface $container The tagged service container
  */
 public function loadTaggedServiceIds(TaggedContainerInterface $container)
 {
     foreach ($container->findTaggedServiceIds('validator.constraint_validator') as $id => $attributes) {
         if (isset($attributes[0]['alias'])) {
             $this->validators[$attributes[0]['alias']] = $id;
         }
     }
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function getStrategy($contextName, $object)
 {
     // prefix.context_name
     $contextServiceId = $this->converter->getServiceNamespace($this->servicePrefix, $contextName);
     // get the correct strategy service by the object
     $strategy = $this->container->get($contextServiceId);
     $strategy = $strategy->getStrategyName($object);
     // get service namespace
     $strategyAlias = $this->converter->getServiceNamespace($this->servicePrefix, array($contextName, $strategy));
     if (!$this->container->has($strategyAlias)) {
         $strategyAlias = $this->container->get($contextServiceId)->getFallbackStrategy();
     }
     return $this->container->get($strategyAlias);
 }
Пример #3
0
 /**
  * Loads event subscribers from the service container.
  *
  *     <service class="MySubscriber">
  *         <tag name="doctrine.odm.mongodb.event_subscriber" />
  *     </service>
  *
  * @param TaggedContainerInterface $container The service container
  * @param string $tagName The name of the tag to load
  */
 public function loadTaggedEventSubscribers(TaggedContainerInterface $container, $tagName = 'doctrine.common.event_listener')
 {
     foreach ($container->findTaggedServiceIds($tagName) as $id => $instances) {
         $this->addEventSubscriber($container->get($id));
     }
 }
 protected function assertServiceHasTag($id, $tag, $attributes = array())
 {
     $services = $this->container->findTaggedServiceIds($tag);
     $this->assertArrayHasKey($id, $services);
     $this->assertContains($attributes, $services[$id]);
 }