/** * @param ParseEvent $event */ public function onClassParsed(ParseEvent $event) { $this->cacheControllers($event->getParam('config'), $event->getParam('scannedConfig')); $this->scannedConfig = $event->getParam('scannedConfig'); // handle class annotations $classHolder = $event->getTarget(); $classAnnotationsCollection = $classHolder->getAnnotations(); $classAnnotations = []; foreach ($classAnnotationsCollection as $annotation) { if (!$annotation instanceof Route) { continue; } $classAnnotations[] = $annotation; $this->handleClassAnnotation($annotation, $classHolder->getClass()); } // handle annotations per method foreach ($classHolder->getMethods() as $methodHolder) { foreach ($methodHolder->getAnnotations() as $methodAnnotation) { if (!$methodAnnotation instanceof Route) { continue; } $this->handleMethodAnnotation($methodAnnotation, $classAnnotations, $classHolder->getClass(), $methodHolder->getMethod()); } } $event->mergeResult(['router' => ['routes' => $this->config]]); }
public function onClassParsed(ParseEvent $event) { $this->resolveControllers($event->getParam('config')); $classHolder = $event->getTarget(); $methodHolders = $classHolder->getMethods(); $config = []; foreach ($methodHolders as $methodHolder) { foreach ($methodHolder->getAnnotations() as $annotation) { $controller = $classHolder->getClass()->getName(); if (isset($this->controllers[$controller])) { $controller = $this->controllers[$controller]; } $method = preg_replace('/Action$/', '', $methodHolder->getMethod()->getName()); if ($annotation instanceof Asserts) { foreach ($annotation->getNames() as $name) { $options = empty($annotation->getOptions()[$name]) ? [] : $annotation->getOptions()[$name]; $config['asserts'][$controller][$method][] = ['assert' => $name, 'options' => $options]; } } if ($annotation instanceof Assert) { $config['asserts'][$controller][$method][] = ['assert' => $annotation->getName(), 'options' => $annotation->getOptions()]; } } } $event->mergeResult($config); }
/** * @param ParseEvent $event */ public function onClassParsed(ParseEvent $event) { $classHolder = $event->getTarget(); $classAnnotations = $classHolder->getAnnotations(); foreach ($classAnnotations as $annotation) { if (!$annotation instanceof Service) { continue; } $this->handleClassAnnotation($annotation, $classHolder->getClass()); } $event->mergeResult($this->definitions); }
public function onClassParsed(ParseEvent $event) { $this->resolveControllers($event->getParam('config')); $config = array(); $classHolder = $event->getTarget(); $controller = $classHolder->getClass()->getName(); if (isset($this->controllers[$controller])) { $controller = $this->controllers[$controller]; } foreach ($classHolder->getAnnotations() as $classAnnotation) { if ($classAnnotation instanceof Acl) { $allow = $classAnnotation->getAllow(); $deny = $classAnnotation->getDeny(); if ($allow) { $config['acl']['resources']['allow'][$controller]['*'] = $allow; } if ($deny) { $config['acl']['resources']['deny'][$controller]['*'] = $deny; } } } $methodHolders = $classHolder->getMethods(); foreach ($methodHolders as $methodHolder) { foreach ($methodHolder->getAnnotations() as $annotation) { if ($annotation instanceof Acl) { $method = preg_replace('/Action$/', '', $methodHolder->getMethod()->getName()); $allow = $annotation->getAllow(); $deny = $annotation->getDeny(); if ($allow) { $config['acl']['resources']['allow'][$controller][$method] = $allow; } if ($deny) { $config['acl']['resources']['deny'][$controller][$method] = $deny; } } } } $event->mergeResult($config); }