Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Bundle.php

function Bundle::getContainerExtension

Returns the bundle's container extension.

Throws

\LogicException

Overrides BundleInterface::getContainerExtension

1 method overrides Bundle::getContainerExtension()
AbstractBundle::getContainerExtension in vendor/symfony/http-kernel/Bundle/AbstractBundle.php
Returns the bundle's container extension.

File

vendor/symfony/http-kernel/Bundle/Bundle.php, line 63

Class

Bundle
An implementation of BundleInterface that adds a few conventions for DependencyInjection extensions.

Namespace

Symfony\Component\HttpKernel\Bundle

Code

public function getContainerExtension() : ?ExtensionInterface {
    if (!isset($this->extension)) {
        $extension = $this->createContainerExtension();
        if (null !== $extension) {
            if (!$extension instanceof ExtensionInterface) {
                throw new \LogicException(\sprintf('Extension "%s" must implement Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface.', get_debug_type($extension)));
            }
            // check naming convention
            $basename = preg_replace('/Bundle$/', '', $this->getName());
            $expectedAlias = Container::underscore($basename);
            if ($expectedAlias != $extension->getAlias()) {
                throw new \LogicException(\sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias()));
            }
            $this->extension = $extension;
        }
        else {
            $this->extension = false;
        }
    }
    return $this->extension ?: null;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal