Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\Bundle;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Console\Application;
@ -24,8 +24,12 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class Bundle extends ContainerAware implements BundleInterface
abstract class Bundle implements BundleInterface
{
/**
* @var ContainerInterface
*/
protected $container;
protected $name;
protected $extension;
protected $path;
@ -58,6 +62,16 @@ abstract class Bundle extends ContainerAware implements BundleInterface
{
}
/**
* Sets the container.
*
* @param ContainerInterface|null $container A ContainerInterface instance or null
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* Returns the bundle's container extension.
*
@ -68,17 +82,17 @@ abstract class Bundle extends ContainerAware implements BundleInterface
public function getContainerExtension()
{
if (null === $this->extension) {
$class = $this->getContainerExtensionClass();
if (class_exists($class)) {
$extension = new $class();
$extension = $this->createContainerExtension();
if (null !== $extension) {
if (!$extension instanceof ExtensionInterface) {
throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', $class));
throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_class($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.',
@ -166,6 +180,10 @@ abstract class Bundle extends ContainerAware implements BundleInterface
return;
}
if (!class_exists('Symfony\Component\Finder\Finder')) {
throw new \RuntimeException('You need the symfony/finder component to register bundle commands.');
}
$finder = new Finder();
$finder->files()->name('*Command.php')->in($dir);
@ -173,7 +191,7 @@ abstract class Bundle extends ContainerAware implements BundleInterface
foreach ($finder as $file) {
$ns = $prefix;
if ($relativePath = $file->getRelativePath()) {
$ns .= '\\'.strtr($relativePath, '/', '\\');
$ns .= '\\'.str_replace('/', '\\', $relativePath);
}
$class = $ns.'\\'.$file->getBasename('.php');
if ($this->container) {
@ -200,4 +218,16 @@ abstract class Bundle extends ContainerAware implements BundleInterface
return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension';
}
/**
* Creates the bundle's container extension.
*
* @return ExtensionInterface|null
*/
protected function createContainerExtension()
{
if (class_exists($class = $this->getContainerExtensionClass())) {
return new $class();
}
}
}