예제 #1
0
 /**
  * class constructor
  *
  * @param ConfigurationManagerInterface $configManager  the configuration manager
  * @param ObjectManager                 $objectManager  the object manager
  * @param SessionHandlerInterface       $sessionHandler the sessionHandlerFactory
  * @param Request                       $request        the request instance
  * @param Response                      $responses      the response instance
  */
 public function __construct(ConfigurationManagerInterface $configManager, ObjectManager $objectManager, SessionHandlerInterface $sessionHandler, Request $request, Response $responses)
 {
     $this->configManager = $configManager;
     $this->objectManager = $objectManager;
     $this->sessionHandler = $sessionHandler;
     $this->request = $request;
     $this->response = $responses;
     $this->request->injectSessionHandler($sessionHandler);
 }
예제 #2
0
 /**
  * checks if a session exists and returns the session instance
  *
  * @param bool $create the create flag
  *
  * @return bool|HttpSessionInterface
  * @throws \Exception
  */
 protected function checkSession($create)
 {
     $cookies = $this->request->getHeader()->getCookies();
     if (!isset($cookies[$this->getSessionName()])) {
         return $this->createSessionIfRequired($create);
     } else {
         return $this->validateSession($this->getSessionName(), $cookies[$this->getSessionName()]);
     }
 }
예제 #3
0
 /**
  * Returns the configured request handler class name for current uri
  *
  * @return mixed
  */
 protected function getHandlerClass()
 {
     $routes = $this->manager->getRoutes();
     foreach ($routes as $route => $handler) {
         if (substr($route, -1) === "\$") {
             $route = substr($route, 0, -1);
             if ($route === $this->request->getUri()) {
                 return $handler;
             }
         } else {
             if (strpos($this->request->getUri(), $route) === 0) {
                 return $handler;
             }
         }
     }
     if (isset($routes["*"])) {
         return $routes["*"];
     }
     return false;
 }