Пример #1
0
 /**
  * Act as an internal constructor.
  * 
  * @param Request request, the request
  * @param Response response, the response
  */
 private function instantiate(Request $request, Response $response)
 {
     // class memebers
     $this->request = $request;
     $this->response = $response;
     $this->params = $request->getParameters();
     $this->logger = Registry::get('__logger');
     $this->injector = Registry::get('__injector');
     $this->config = Registry::get('__configurator');
     $this->session = $request->getSession();
     $this->app_path = $this->injector->getPath('__base');
     $this->template_root = $this->injector->getPath('views') . $this->params['controller'] . DIRECTORY_SEPARATOR;
     $this->template = ActionView::factory('php');
     // register session container if any
     // TODO: this should be moved elsewhere
     if ($this->config->getWebContext()->session !== NULL && $this->config->getWebContext()->session->container !== NULL) {
         // container location.
         $c_location = str_replace('.', DIRECTORY_SEPARATOR, (string) $this->config->getWebContext()->session->container) . '.php';
         include_once $c_location;
         // container class name.
         $e = explode('.', (string) $this->config->getWebContext()->session->container);
         // reflect on container.
         $container = new ReflectionClass(end($e));
         if ($container->implementsInterface('ISessionContainer')) {
             $this->session->setContainer($container->newInstance());
         }
     }
     // predefined variables:
     // TODO: check if we have a / at the end, if not, add one
     $this->template->assign('__base', (string) $this->config->getWebContext()->document_root);
     $this->template->assign('__server', (string) $this->config->getWebContext()->server_name);
     $this->template->assign('__controller', $this->params['controller']);
     $this->template->assign('__version', Medick::getVersion());
     $this->template->assign('__self', $this->__base . $this->request->getRequestUri());
     $this->logger->debug($this->request->toString());
 }