/** * {@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); }
/** * 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 assertHasService($id, $instanceOf) { $this->assertTrue($this->container->has($id)); $this->assertInstanceOf($instanceOf, $this->container->get($id)); }