initializeContainer example

public function getProjectDir(): string
    {
        return __DIR__;
    }

    protected function initializeContainer(): void
    {
        if ($this->fakeContainer) {
            $this->container = new ContainerBuilder();
        } else {
            parent::initializeContainer();
        }
    }
}
$this->serviceProviderClasses['app']['update_kernel'] = 'Drupal\Core\Update\UpdateServiceProvider';
  }

  /** * {@inheritdoc} */
  protected function initializeContainer() {
    // Always force a container rebuild, in order to be able to override some     // services, see \Drupal\Core\Update\UpdateServiceProvider.     $this->containerNeedsRebuild = TRUE;
    $container = parent::initializeContainer();
    return $container;
  }

  /** * {@inheritdoc} */
  protected function cacheDrupalContainer(array $container_definition) {
    // Don't save this particular container to cache, so it does not leak into     // the main site at all.     return FALSE;
  }

  

        if ($this->booted) {
            return;
        }

        if (!$skipDatabase) {
            $dbConn = $this->config['db'];
            $this->connection = Components\DependencyInjection\Bridge\Db::createPDO($dbConn);
            $this->initializePlugins();
        }

        $this->initializeContainer();
        $this->initializeShopware();

        foreach ($this->getBundles() as $bundle) {
            $bundle->setContainer($this->container);

            if ((!$bundle instanceof Plugin) || $bundle->isActive()) {
                $bundle->boot();
            }

            if (!$bundle instanceof Plugin) {
                continue;
            }
      // https://www.drupal.org/node/2447753.       if (function_exists('apcu_fetch')) {
        $configuration['default']['cache_backend_class'] = '\Drupal\Component\FileCache\ApcuFileCacheBackend';
      }
    }
    FileCacheFactory::setConfiguration($configuration);
    FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));

    $this->bootstrapContainer = new $this->bootstrapContainerClass(Settings::get('bootstrap_container_definition', $this->defaultBootstrapContainerDefinition));

    // Initialize the container.     $this->initializeContainer();

    // Add the APCu prefix to use to cache found/not-found classes.     if (Settings::get('class_loader_auto_detect', TRUE) && method_exists($this->classLoader, 'setApcuPrefix')) {
      // Vary the APCu key by which modules are installed to allow       // class_exists() checks to determine functionality.       $id = 'class_loader:' . crc32(implode(':', array_keys($this->container->getParameter('container.modules'))));
      $prefix = Settings::getApcuPrefix($id$this->root);
      $this->classLoader->setApcuPrefix($prefix);
    }

    $this->booted = TRUE;

    

        if ($this->debug) {
            $this->startTime = microtime(true);
        }
        if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) {
            putenv('SHELL_VERBOSITY=3');
            $_ENV['SHELL_VERBOSITY'] = 3;
            $_SERVER['SHELL_VERBOSITY'] = 3;
        }

        $this->initializeBundles();
        $this->initializeContainer();

        $container = $this->container;

        if ($container->hasParameter('kernel.trusted_hosts') && $trustedHosts = $container->getParameter('kernel.trusted_hosts')) {
            Request::setTrustedHosts($trustedHosts);
        }

        if ($container->hasParameter('kernel.trusted_proxies') && $container->hasParameter('kernel.trusted_headers') && $trustedProxies = $container->getParameter('kernel.trusted_proxies')) {
            Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies))$container->getParameter('kernel.trusted_headers'));
        }

        

        if ($this->debug) {
            $this->startTime = microtime(true);
        }
        if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) {
            putenv('SHELL_VERBOSITY=3');
            $_ENV['SHELL_VERBOSITY'] = 3;
            $_SERVER['SHELL_VERBOSITY'] = 3;
        }

        $this->initializeBundles();
        $this->initializeContainer();

        $container = $this->container;

        if ($container->hasParameter('kernel.trusted_hosts') && $trustedHosts = $container->getParameter('kernel.trusted_hosts')) {
            Request::setTrustedHosts($trustedHosts);
        }

        if ($container->hasParameter('kernel.trusted_proxies') && $container->hasParameter('kernel.trusted_headers') && $trustedProxies = $container->getParameter('kernel.trusted_proxies')) {
            Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies))$container->getParameter('kernel.trusted_headers'));
        }

        
$this->pluginLoader->initializePlugins($this->getProjectDir());
        } catch (\Throwable $e) {
            if (\defined('\STDERR')) {
                fwrite(\STDERR, 'Warning: Failed to load plugins. Message: ' . $e->getMessage() . \PHP_EOL);
            }
        }

        // init bundles         $this->initializeBundles();

        // init container         $this->initializeContainer();

        // Taken from \Symfony\Component\HttpKernel\Kernel::preBoot()         /** @var ContainerInterface $container */
        $container = $this->container;

        if ($container->hasParameter('kernel.trusted_hosts') && $trustedHosts = $container->getParameter('kernel.trusted_hosts')) {
            Request::setTrustedHosts($trustedHosts);
        }

        if ($container->hasParameter('kernel.trusted_proxies') && $container->hasParameter('kernel.trusted_headers') && $trustedProxies = $container->getParameter('kernel.trusted_proxies')) {
            \assert(\is_string($trustedProxies) || \is_array($trustedProxies));
            

class InstallerKernel extends DrupalKernel {

  /** * {@inheritdoc} */
  protected function initializeContainer() {
    // Always force a container rebuild.     $this->containerNeedsRebuild = TRUE;
    // Ensure the InstallerKernel's container is not dumped.     $this->allowDumping = FALSE;
    $container = parent::initializeContainer();
    return $container;
  }

  /** * Reset the bootstrap config storage. * * Use this from a database driver runTasks() if the method overrides the * bootstrap config storage. Normally the bootstrap config storage is not * re-instantiated during a single install request. Most drivers will not * need this method. * * @see \Drupal\Core\Database\Install\Tasks::runTasks() */
Home | Imprint | This part of the site doesn't use cookies.