Beispiel #1
0
 /**
  * @return Nette\Application\Application
  */
 public static function createServiceApplication(DI\Container $container, array $options = NULL)
 {
     $context = new DI\Container();
     $context->addService('httpRequest', $container->httpRequest);
     $context->addService('httpResponse', $container->httpResponse);
     $context->addService('session', $container->session);
     $context->addService('presenterFactory', $container->presenterFactory);
     $context->addService('router', $container->router);
     Nette\Application\UI\Presenter::$invalidLinkMode = $container->params['productionMode'] ? Nette\Application\UI\Presenter::INVALID_LINK_SILENT : Nette\Application\UI\Presenter::INVALID_LINK_WARNING;
     $class = isset($options['class']) ? $options['class'] : 'Nette\\Application\\Application';
     $application = new $class($context);
     $application->catchExceptions = $container->params['productionMode'];
     if ($container->session->exists()) {
         $application->onStartup[] = function () use($container) {
             $container->session->start();
             // opens already started session
         };
     }
     return $application;
 }