/** * * @param GenerationContext $context * @param \Nucleus\IService\FrontController\ViewDefinition $annotation */ public function generate(GenerationContext $context, $annotation) { $serviceName = $context->getServiceName(); $methodName = $context->getParsingContextName(); $controllerViewConciliatorDefinition = $context->getContainerBuilder()->getDefinition('controllerViewConciliator'); $controllerViewConciliatorDefinition->addMethodCall('setViewDefinition', array($serviceName . '/' . $methodName, $annotation->name, $annotation->template, $annotation->variables)); }
/** * * @param GenerationContext $context * @param \Nucleus\IService\CommandLine\Consolable $annotation */ public function generate(GenerationContext $context, $annotation) { $docParser = new DocBlockParser(); $serviceName = $context->getServiceName(); $methodName = $context->getParsingContextName(); $definition = $context->getContainerBuilder()->getDefinition($serviceName); $shortDesc = 'N/A'; $reflectedMethod = new \ReflectionMethod($definition->getClass(), $methodName); $methodComment = $reflectedMethod->getDocComment(); if ($methodComment !== false) { $docMethod = $docParser->parse($methodComment); $shortDesc = $docMethod->getShortDesc(); } $paramsArray = array(); $paramArrayComments = self::extractParamDocComment($docMethod->getTag('param')); foreach ($reflectedMethod->getParameters() as $reflectionParameter) { $paramComment = 'N/A'; if (isset($paramArrayComments[$reflectionParameter->getName()])) { $paramComment = $paramArrayComments[$reflectionParameter->getName()]['comment']; } $paramsArray[$reflectionParameter->getName()]['optional'] = false; if ($reflectionParameter->isDefaultValueAvailable()) { $paramsArray[$reflectionParameter->getName()]['optional'] = true; } $paramsArray[$reflectionParameter->getName()]['comment'] = $paramComment; } if (!empty($annotation->name)) { $name = $annotation->name; } else { $name = $serviceName . ':' . $methodName; } $context->getContainerBuilder()->getDefinition("console")->addMethodCall("addCommand", array("applicatiomName" => $name, "serviceName" => $serviceName, "methodName" => $methodName, "shortDesc" => $shortDesc, "paramsMethod" => $paramsArray)); }
/** * This method is use by the I18nRouteAnnotationParser * * @param \Nucleus\IService\Routing\Route $route * @param \Nucleus\DependencyInjection\GenerationContext $context */ private function addRoute(Route $route, GenerationContext $context) { //We don't add route with no name or no path if (!$route->getName() || !$route->getPath()) { return; } $defaults = $route->getDefaults(); $defaults['_service'] = array('name' => $context->getServiceName(), 'method' => $context->getParsingContextName()); $arguments = array($route->getName(), $route->getPath(), $defaults, $route->getRequirements(), $route->getOptions(), $route->getHost(), $route->getSchemes(), $route->getMethods()); $context->getContainerBuilder()->getDefinition("routing")->addMethodCall('addRoute', $arguments); }
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 * @param \Nucleus\IService\Dashboard\Controller $annotation */ public function generate(GenerationContext $context, $annotation) { $serviceName = $context->getServiceName(); $dashboard = $context->getContainerBuilder()->getDefinition('dashboard'); if (!($name = $annotation->name)) { $def = $context->getContainerBuilder()->getDefinition($serviceName); $classname = $def->getClass(); $name = substr($classname, strrpos($classname, '\\') + 1); } $dashboard->addMethodCall('addServiceAsController', array($serviceName, $name)); }
/** * @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) { $definition = $context->getServiceDefinition(); $serviceName = $context->getServiceName(); $currentCode = $definition->getCodeInitalization(); $serviceBinderAssignation = ' $sessionServiceBinder = $serviceContainer->getServiceByName("sessionServiceBinder"); '; if (strpos($currentCode, $serviceBinderAssignation) === false) { $currentCode .= $serviceBinderAssignation; } $currentCode .= ' $sessionServiceBinder->addBindingAttribute("' . $serviceName . '","' . $context->getParsingContextName() . '"); '; $restoreFromSession = ' $sessionServiceBinder->restoreFromSession($service,"' . $serviceName . '"); '; $finalCode = str_replace($restoreFromSession, "", $currentCode); $finalCode .= $restoreFromSession; $definition->setCodeInitialization($finalCode); }
/** * * @param GenerationContext $context * @param \Nucleus\IService\View\IViewDefinition $annotation */ public function generate(GenerationContext $context, $annotation) { $serviceName = $context->getServiceName(); $methodName = $context->getParsingContextName(); $definition = $context->getContainerBuilder()->getDefinition(IViewConciliator::NUCLEUS_SERVICE_NAME); }