Extension.php in Service Container 7.2
File
modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Extension/Extension.php
View source
<?php
namespace Symfony\Component\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Definition\ConfigurationInterface;
abstract class Extension implements ExtensionInterface, ConfigurationExtensionInterface {
public function getXsdValidationBasePath() {
return false;
}
public function getNamespace() {
return 'http://example.org/schema/dic/' . $this
->getAlias();
}
public function getAlias() {
$className = get_class($this);
if (substr($className, -9) != 'Extension') {
throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
}
$classBaseName = substr(strrchr($className, '\\'), 1, -9);
return Container::underscore($classBaseName);
}
public function getConfiguration(array $config, ContainerBuilder $container) {
$reflected = new \ReflectionClass($this);
$namespace = $reflected
->getNamespaceName();
$class = $namespace . '\\Configuration';
if (class_exists($class)) {
$r = new \ReflectionClass($class);
$container
->addResource(new FileResource($r
->getFileName()));
if (!method_exists($class, '__construct')) {
$configuration = new $class();
return $configuration;
}
}
}
protected final function processConfiguration(ConfigurationInterface $configuration, array $configs) {
$processor = new Processor();
return $processor
->processConfiguration($configuration, $configs);
}
protected function isConfigEnabled(ContainerBuilder $container, array $config) {
if (!array_key_exists('enabled', $config)) {
throw new InvalidArgumentException("The config array has no 'enabled' key.");
}
return (bool) $container
->getParameterBag()
->resolveValue($config['enabled']);
}
}
Classes
Name |
Description |
Extension |
Provides useful features shared by many extensions. |