Ejemplo n.º 1
0
 /**
  * @return KernelInterface
  */
 public function getKernel()
 {
     if (null === $this->httpKernel) {
         $this->httpKernel = self::createKernel();
         $this->httpKernel->boot();
         $this->container = $this->httpKernel->getContainer();
     }
     return $this->httpKernel;
 }
Ejemplo n.º 2
0
/**
 * Sets the global environment
 *
 * @param KernelInterface $kernel            
 * @throws \RuntimeException
 * @return \Kernelstudio\Component\Container\ContainerInterface
 * @since 0.1
 */
function ks_setup_environment($kernel)
{
    if (!$kernel instanceof Bridge\Component\Kernel\KernelInterface) {
        throw new \RuntimeException('The kernel must be an instance of [ Bridge\\Component\\Kernel\\KernelInterface ]');
    }
    global $ks_container;
    if (!$ks_container instanceof \Kernelstudio\Component\Container\ContainerInterface) {
        $ks_container = $kernel->getContainer();
    }
    return $ks_container;
}
 protected function registerContainerConfiguration(KernelInterface $kernel, ContainerBuilder $containerBuilder, LoaderInterface $loader)
 {
     // Register core services
     $containerBuilder->register("kernel", KernelInterface::class)->setSynthetic(true);
     $containerBuilder->register("event_dispatcher", EventDispatcher::class);
     $containerBuilder->register("kernel.task_collection", TaskCollection::class);
     // Then core compiler passes
     $containerBuilder->addCompilerPass(new RegisterListenersPass())->addCompilerPass(new RegisterTasksPass());
     // Register modules configuration
     foreach ($kernel->getRegisteredModules() as $module) {
         if ($module instanceof SfContainerInitializerModuleInterface) {
             $module->buildContainer($containerBuilder);
             if (null !== ($cont = $module->registerContainerConfiguration($loader))) {
                 $containerBuilder->merge($cont);
             }
         }
     }
 }