/** * Returns the schema for an array of behaviors * * @param array $behaviors * @return array */ public function getBehaviorsSchema($controller, $action) { $array = array(); foreach ($action->getBehaviors() as $b) { $array[$b->getName()] = $b->getParams(); if ($b->isInvokable()) { $array[$b->getName()]['url'] = $this->routing->generate('dashboard.invokeBehavior', array('controllerName' => $controller->getName(), 'actionName' => $action->getName(), 'behaviorName' => $b->getName())); } } return $array; }
/** * * @param type $serviceName * @param type $methodName * @param Request $request * * @return Response */ public function execute($serviceName, $methodName, Request $request, Response $response = null) { $this->routing->setCurrentRequest($request); if (is_null($response)) { $response = new Response(); } $this->eventDispatcher->dispatch('FrontController.preExecute', $this, compact('serviceName', 'methodName', 'response', 'request')); $parameters = array_merge($request->query->all(), $request->request->all()); $service = $this->serviceContainer->getServiceByName($serviceName); try { $executionResult = $this->invoker->invoke(array($service, $methodName), $parameters, array($request, $response)); } catch (Exception $e) { $executionResult = $this->frontControllerExceptionHandler->handleException($e, $request, $response); } $finalResponse = $this->completeResponse($executionResult, $request, $response); $finalResponse->prepare($request); $this->eventDispatcher->dispatch("Response.beforeSend", $finalResponse); return $finalResponse; }
/** * * @param $serviceName The name of the service * @param $class A class name that need to be register as service and being parse * * @return Nucleus\IService\Routing\Router */ protected function getRoutingService($serviceName, $class) { return Router::factory(array('imports' => array(__DIR__ . '/../'), 'services' => array($serviceName => array('class' => $class)))); }
/** * * @return Nucleus\Routing\Router */ protected function getRoutingService() { return Router::factory(); }