public static function executeAction($controllerName, $actionName, $actionParams, $areaName) { $manager = ApplicationManager::getInstance(); $controllerFactory = $manager->getControllerFactory(); $viewEngine = $manager->getViewEngine(); $controller = $controllerFactory->createController($controllerName, $areaName); $helper = new AnnotationHelper(new AnnotationFactory()); $controllerAnnotations = $helper->extractAnnotations(get_class($controller)); $actionAnnotations = $helper->extractAnnotations(get_class($controller), $actionName); $annotationProcessor = new AnnotationProcessor(); $annotationProcessor->processAnnotations($controllerAnnotations); $annotationProcessor->processAnnotations($actionAnnotations); $invoker = new ActionInvoker($controller, $actionName, $actionParams); $actionArgs = $invoker->processBinding(); $actionResult = $invoker->executeAction($actionArgs); $resultHandler = new ActionResultHandler($viewEngine, $areaName); $resultHandler->handleResult($actionResult); }
private function getRouteAnnotations($controller) { $reflection = new \ReflectionClass($controller); $methods = $reflection->getMethods(); $helper = new AnnotationHelper(new AnnotationFactory()); $annotations = array(); foreach ($methods as $method) { if ($method->isPublic() && $method->name != '__construct') { $actionAnnotations = $helper->extractAnnotations($controller, $method->name); $actionRouteAnnotations = array_filter($actionAnnotations, function ($value) { if ($value instanceof RouteAnnotation) { return true; } return false; }); $actionAnnotationsDictionary = array(); foreach ($actionRouteAnnotations as $annotation) { $actionAnnotationsDictionary[] = array($method->name, $annotation); } $annotations = array_merge($actionAnnotationsDictionary, $annotations); } } return $annotations; }