/** * @param Symfony\Components\DependencyInjection\ContainerInterface $container * @param Symfony\Components\HttpKernel\HttpKernelInterface $kernel * @param array $options (optional) */ public function __construct(ContainerInterface $container, HttpKernelInterface $kernel, array $options) { parent::__construct($container); $this->kernel = $kernel; $this->customKernel = null; $this->options = array('kernel_environment' => 'dev', 'kernel_debug' => true, 'hostname' => 'localhost', 'admin' => 'root@localhost', 'hostname_lookups' => false, 'document_root' => $this->kernel->getRootDir() . '/../web'); // check option names if ($diff = array_diff(array_keys($options), array_keys($this->options))) { throw new \InvalidArgumentException(sprintf('The Server does not support the following options: \'%s\'.', implode('\', \'', $diff))); } $this->options = array_merge($this->options, $options); // realpath document root $this->options['document_root'] = realpath($this->options['document_root']); // start a custom kernel if needed if ($this->options['kernel_environment'] != $this->kernel->getEnvironment() || $this->options['kernel_debug'] != $this->kernel->isDebug()) { $class = get_class($kernel); $this->customKernel = new $class($this->options['kernel_environment'], $this->options['kernel_debug']); $this->customKernel->boot(); } }
/** * @param Symfony\Components\DependencyInjection\ContainerInterface $container * @param string $documentRoot */ public function __construct(ContainerInterface $container, $documentRoot) { parent::__construct($container); $this->documentRoot = realpath($documentRoot); }