public function Kernel::getBundle

Returns a bundle and optionally its descendants by its name.

@api

Parameters

string $name Bundle name:

Boolean $first Whether to return the first bundle only or together with its descendants:

Return value

BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false

Throws

\InvalidArgumentException when the bundle is not enabled

Overrides KernelInterface::getBundle

1 call to Kernel::getBundle()
Kernel::locateResource in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php
Returns the file path for a given resource.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php, line 250

Class

Kernel
The Kernel is the heart of the Symfony system.

Namespace

Symfony\Component\HttpKernel

Code

public function getBundle($name, $first = true) {
  if (!isset($this->bundleMap[$name])) {
    throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() function of your %s.php file?', $name, get_class($this)));
  }
  if (true === $first) {
    return $this->bundleMap[$name][0];
  }
  return $this->bundleMap[$name];
}