public function processContainerBuilder(GenerationContext $context) { $method = $context->getParsingContextName(); $definition = $context->getServiceDefinition(); $parameters = $this->getParameters($definition->getClass(), $method, $context->getServiceName(), $context->getAnnotation()); if ($method == "__construct") { $definition->setArguments($parameters); } else { $definition->addMethodCall($method, $parameters); } }
/** * @param GenerationContext $context */ public function processContainerBuilder(GenerationContext $context) { $serviceName = $context->getServiceName(); $annotation = $context->getAnnotation(); /* @var $annotation \Nucleus\IService\EventDispatcher\Listen */ if (is_null($annotation->eventName)) { throw new \Exception('Attribute value [eventName] for annotation [Listen] is required'); } $context->getContainerBuilder()->getDefinition(IEventDispatcherService::NUCLEUS_SERVICE_NAME)->addCodeInitialization(' $service->addListener( "' . $annotation->eventName . '", function(\\Nucleus\\IService\\EventDispatcher\\IEvent $event) use ($serviceContainer) { $listener = array($serviceContainer->getServiceByName("' . $serviceName . '"),"' . $context->getParsingContextName() . '"); $serviceContainer->getServiceByName(\\Nucleus\\IService\\Invoker\\IInvokerService::NUCLEUS_SERVICE_NAME) ->invoke($listener,$event->getParameters(),array($event, $event->getSubject())); }, ' . $annotation->priority . ' ); '); }
/** * @param GenerationContext $context */ public function processContainerBuilder(GenerationContext $context) { $annotation = $context->getAnnotation(); $this->addRoute($annotation, $context); if (!$annotation instanceof I18nRoute) { return; } /* @var $annotation \Nucleus\IService\Routing\I18nRoute */ foreach ($annotation->getRoutes() as $culture => $route) { foreach (array('Name', 'Defaults', 'Requirements', 'Options', 'Host', 'Schemes', 'Methods') as $method) { $getter = 'get' . $method; if ($route->{$getter}()) { throw new InvalidArgumentException('Route [' . $this->getName() . '] for culture [' . $culture . '] cannot have a value for [' . $method . ']'); } } $route->setName($annotation->getName()); $defaults = $annotation->getDefaults(); $defaults['_culture'] = $culture; $route->setDefaults($defaults); $this->addRoute($route, $context); } }