예제 #1
0
 /**
  * creates a new class instance of given class name
  *
  * @param string $requestHandlerClassName the request handler class name
  *
  * @return mixed
  * @throws \Exception
  */
 protected function getHandlerInstance($requestHandlerClassName)
 {
     $class = $requestHandlerClassName;
     // if class name has no namespace add the default handler namespace
     if (strpos($requestHandlerClassName, "\\") === false) {
         $class = self::HANDLER_NAMESPACE . $requestHandlerClassName;
     }
     if (!class_exists($class)) {
         throw new \Exception($requestHandlerClassName);
     }
     return new $class($this->manager, $this->objectManager, $this->sessionHandlerFactory->getInstance(), $this->request, $this->response);
 }
예제 #2
0
 /**
  * application starter
  *
  * @return void
  */
 public function start()
 {
     try {
         // creates the doctrine entity manager if database settings are given.
         // the instance will be stored in the object manager
         $this->createEntityManager();
         $requestHandler = $this->requestHandlerFactory->getInstance();
         $requestHandler->process();
         // process session handling after request handling is finished
         $this->sessionHandlerFactory->getInstance()->afterProcess();
     } catch (InvalidControllerException $e) {
         $this->response->setContent($e->getMessage());
         $this->response->setHttpStatus(Http::STATUS_NOT_FOUND);
     } catch (InvalidControllerActionException $e) {
         $this->response->setContent($e->getMessage());
         $this->response->setHttpStatus(Http::STATUS_NOT_FOUND);
     }
     $this->renderResponse();
 }