public function DrupalKernel::registerBundles

Returns an array of available bundles.

Return value

array The available bundles.

Overrides KernelInterface::registerBundles

File

drupal/core/lib/Drupal/Core/DrupalKernel.php, line 181
Definition of Drupal\Core\DrupalKernel.

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

public function registerBundles() {
  $this->configStorage = BootstrapConfigStorageFactory::get();
  $bundles = array(
    new CoreBundle(),
  );
  $this->serviceYamls = array(
    'core/core.services.yml',
  );
  $this->bundleClasses = array(
    'Drupal\\Core\\CoreBundle',
  );

  // Ensure we know what modules are enabled and that their namespaces are
  // registered.
  if (!isset($this->moduleList)) {
    $module_list = $this->configStorage
      ->read('system.module');
    $this->moduleList = isset($module_list['enabled']) ? $module_list['enabled'] : array();
  }
  $module_filenames = $this
    ->getModuleFileNames();
  $this
    ->registerNamespaces($this
    ->getModuleNamespaces($module_filenames));

  // Load each module's bundle class.
  foreach ($this->moduleList as $module => $weight) {
    $camelized = ContainerBuilder::camelize($module);
    $class = "Drupal\\{$module}\\{$camelized}Bundle";
    if (class_exists($class)) {
      $bundles[] = new $class();
      $this->bundleClasses[] = $class;
    }
    $filename = dirname($module_filenames[$module]) . "/{$module}.services.yml";
    if (file_exists($filename)) {
      $this->serviceYamls[] = $filename;
    }
  }

  // Add site specific or test bundles.
  if (!empty($GLOBALS['conf']['container_bundles'])) {
    foreach ($GLOBALS['conf']['container_bundles'] as $class) {
      $bundles[] = new $class();
      $this->bundleClasses[] = $class;
    }
  }

  // Add site specific or test YAMLs.
  if (!empty($GLOBALS['conf']['container_yamls'])) {
    $this->serviceYamls = array_merge($this->serviceYamls, $GLOBALS['conf']['container_yamls']);
  }
  return $bundles;
}