HosipLan

Untitled

Oct 7th, 2011
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. # ... configurator
  2.  
  3.     /**
  4.      * @param Nette\DI\Container $container
  5.      * @param array $options
  6.      * @return Kdyby\Application\Application
  7.      */
  8.     public static function createServiceApplication(Nette\DI\Container $container, array $options = NULL)
  9.     {
  10.         $context = new Container;
  11.         $context->addService('httpRequest', $container->httpRequest);
  12.         $context->addService('httpResponse', $container->httpResponse);
  13.         $context->addService('session', $container->session);
  14.         $context->addService('presenterFactory', $container->presenterFactory);
  15.         $context->addService('router', $container->router);
  16.         $context->lazyCopy('requestManager', $container);
  17.         $context->lazyCopy('console', $container);
  18.  
  19.         Presenter::$invalidLinkMode = $container->getParam('productionMode', TRUE)
  20.             ? Presenter::INVALID_LINK_SILENT : Presenter::INVALID_LINK_WARNING;
  21.  
  22.         $application = new Kdyby\Application\Application($context);
  23.         $application->catchExceptions = $container->getParam('productionMode', TRUE);
  24.         $application->errorPresenter = 'Error';
  25.  
  26.         return $application;
  27.     }
  28.  
  29.  
  30. # ... application
  31.  
  32.     /********************* request serialization *********************/
  33.  
  34.  
  35.  
  36.     /**
  37.      * @return RequestManager
  38.      */
  39.     protected function getRequestManager()
  40.     {
  41.         return $this->context->requestManager;
  42.     }
  43.  
  44.  
  45.  
  46.     /**
  47.      * Stores current request to session.
  48.      * @param  mixed  optional expiration time
  49.      * @return string key
  50.      */
  51.     public function storeRequest($expiration = '+ 10 minutes')
  52.     {
  53.         return $this->getRequestManager()->storeCurrentRequest($expiration);;
  54.     }
  55.  
  56.  
  57.  
  58.     /**
  59.      * Restores current request to session.
  60.      * @param  string key
  61.      * @return void
  62.      */
  63.     public function restoreRequest($key)
  64.     {
  65.         $this->getRequestManager()->restoreRequest($key);
  66.     }
  67.  
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment