/** * Request listener. * * @param ResponseEvent $event */ public function onRequest(ResponseEvent $event) { $router = new Router($this->collection); $request = $event->getRequest(); $this->kernel = $event->getKernel(); $this->container = $this->kernel->getContainer(); $this->middleware = $this->kernel->getMiddleware(); $this->responseEvent = $event; $this->container->register('router', $router, true); $router->setHandler($this); $router->listen(new RequestContext($request->getUri()->getPathInfo(), $request->getMethod(), $request->getQueryString(), $request->getSchemaHost()->getHost(), $request->getSchemaHost()->getSchema(), $request->getSchemaHost()->getPort())); }
/** * @return LoggerInterface|null */ protected function getLogger() { if (!$this->kernel->getContainer()->has('log')) { return null; } return $this->kernel->getContainer()->get('log'); }
/** * {@inheritdoc} */ public function build(KernelInterface $kernel) { $this->kernel = $kernel; $this->container = $kernel->getContainer(); $this->reflection = new ReflectionClass(get_called_class()); $this->registerExceptionHandler(); }
/** * Load console from extension. * * @param KernelInterface $kernel */ private function loadConsoles(KernelInterface $kernel) { foreach ($kernel->getBundleManager()->all() as $bundle) { foreach ((array) $bundle->getContainerExtensions() as $extension) { if ($extension instanceof LoadConsoleInterface) { $this->add((array) $extension->loadConsole(), $kernel->getContainer()); } } } }
/** * {@inheritdoc} */ public function initialize(KernelInterface $kernel) { $this->container = $kernel->getContainer(); $this->serviceLocator = $kernel->getServiceLocator(); $env = $kernel->getEnvironmentManager()->getEnvInstance(); $resolver = $this->container->getParameterBag()->getResolver(); $configs = (array) $env->registerConfigurations(); $configs = $this->getResource()->process(new FileLoader(), $configs); $this->loadParametersFromConfig($configs); $this->loadServicesFromConfig($configs); // Append configuration by extension foreach ($resolver->resolveValue($configs) as $alias => $config) { if (!$this->getExtension()->has($alias)) { throw new RuntimeException(sprintf('Extension with alias "%s" not found.', $alias)); } $extension = $this->getExtension()->get($alias); $this->getConfiguration()->prepend($extension->getConfigDefinition(), array($config)); } }
/** * {@inheritdoc} */ public function initialize(KernelInterface $kernel) { $middlewareContainer = $kernel->getMiddleware(); $container = $kernel->getContainer(); $env = $kernel->getEnvironmentManager()->getEnvInstance(); $middlewareContainer->setContainer($container); $bundleMiddlewares = (array) $kernel->registerMiddlewares(); $envMiddlewares = (array) $env->registerMiddlewares(); foreach (array_merge($bundleMiddlewares, $envMiddlewares) as $middleware) { if ($middleware instanceof MiddlewareInterface) { if ($middleware instanceof ContainerAwareInterface) { $middleware->setContainer($container); } $middlewareContainer->set($middleware); continue; } throw new InvalidArgumentException(sprintf('Class "%s" should implement "%s".', get_class($middleware), 'Borobudur\\Kernel\\Middleware\\MiddlewareInterface')); } }
/** * Initialize process process. * * @param KernelInterface $kernel */ public function initialize(KernelInterface $kernel) { $serviceLocator = $kernel->getServiceLocator(); $serviceLocator->getExtension()->load($serviceLocator->getConfiguration(), $kernel->getContainer()); }