Symfony\Component\DependencyInjection\ContainerBuilder::getExtension PHP Method

getExtension() public method

Returns an extension by alias or namespace.
public getExtension ( string $name ) : Symfony\Component\DependencyInjection\Extension\ExtensionInterface
$name string An alias or a namespace
return Symfony\Component\DependencyInjection\Extension\ExtensionInterface An extension instance
    public function getExtension($name)
    {
        if (isset($this->extensions[$name])) {
            return $this->extensions[$name];
        }

        if (isset($this->extensionsByNs[$name])) {
            return $this->extensionsByNs[$name];
        }

        throw new LogicException(sprintf('Container extension "%s" is not registered', $name));
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function build(ContainerBuilder $container)
 {
     /** @var  PayumExtension $payumExtension */
     $payumExtension = $container->getExtension('payum');
     $payumExtension->addGatewayFactory(new JmsGatewayFactory());
     $payumExtension->addGatewayFactory(new FooBarGatewayPaymentFactory());
 }
All Usage Examples Of Symfony\Component\DependencyInjection\ContainerBuilder::getExtension