Returns a bundle and optionally its descendants by its name.
@api
string $name Bundle name:
Boolean $first Whether to return the first bundle only or together with its descendants:
BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false
\InvalidArgumentException when the bundle is not enabled
Overrides KernelInterface::getBundle
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];
}