コード例 #1
0
ファイル: TwigEngine.php プロジェクト: vianneyb/pyrite
 public function __construct(Container $container)
 {
     $rootDir = $container->getParameter('root_dir');
     $productionMode = $container->getParameter('production_mode');
     $loader = new \Twig_Loader_Filesystem($rootDir);
     $this->twig = new \Twig_Environment($loader, array('cache' => $rootDir . '/tmp', 'debug' => !($productionMode === true)));
 }
コード例 #2
0
ファイル: StackedHttpKernel.php プロジェクト: evaneos/pyrite
 /**
  * Get a factory given a service name
  *
  * @param  string            $factoryName Service name to get factory from
  * @throws \RuntimeException Throws a exception if service does not implment HttpKernelFactory
  *
  * @return \Pyrite\Factory\HttpKernelFactory a factory for a service
  */
 private function getFactory($factoryName)
 {
     $factory = $this->container->get($factoryName);
     if (!$factory instanceof HttpKernelFactory) {
         throw new \RuntimeException(sprintf("Object of class %s does not implement Pyrite\\Factory\\HttpKernelFactory interface", get_class($factory)));
     }
     return $factory;
 }
コード例 #3
0
ファイル: TwigEngine.php プロジェクト: evaneos/pyrite
 public function __construct(Container $container)
 {
     $rootDir = $container->getParameter('root_dir');
     $productionMode = $container->getParameter('production_mode');
     $debug = !$productionMode;
     $loader = new \Twig_Loader_Filesystem($rootDir);
     $this->twig = new \Twig_Environment($loader, array('cache' => $rootDir . '/tmp', 'debug' => $debug));
     if ($debug && class_exists(VarCloner::class) && class_exists(DumpExtension::class)) {
         $this->twig->addExtension(new DumpExtension(new VarCloner()));
     }
 }
コード例 #4
0
ファイル: PyriteKernel.php プロジェクト: vianneyb/pyrite
 private function configOnCrashOutput()
 {
     try {
         $this->uncaughtRenderer = $this->container->get("AppOnCrashHandler");
     } catch (\Exception $e) {
         $this->uncaughtRenderer = new \Pyrite\Exception\UncaughtExceptionRendererImpl(false);
     }
     return $this->uncaughtRenderer;
 }
コード例 #5
0
ファイル: PyriteKernel.php プロジェクト: evaneos/pyrite
 /**
  * @return ContainerInterface
  */
 public function startContainer()
 {
     if (true === $this->isStarted()) {
         return $this->container;
     }
     $configAsArray = iterator_to_array($this->config->getIterator());
     $this->internalConfig['parameters'] = $configAsArray;
     $this->container = $this->createContainer(new ArrayConfig($this->internalConfig));
     $loggerFactory = new LoggerFactory($this->config->get('debug'), $this->config->get('log_dir'));
     $this->container->bind('LoggerFactory', $loggerFactory);
     if (null !== $this->router) {
         // Keep compatibility, use the right type hint in the application as usual (UrlGeneratorInterface, UrlMatcherInterface)
         $this->container->bind('UrlMatcher', $this->router->getUrlMatcher());
         $this->container->bind('UrlGenerator', $this->router->getUrlGenerator());
         $this->container->bind('RouteCollection', $this->router->getRouteCollection());
     }
     $this->container->bind('AppLogger', $this->loggerFactory->getLogger('app'));
     $this->started = true;
     return $this->container;
 }