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

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ClassResolver.
*/
namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ClassResolverInterface.
*/
namespace Drupal\Core\DependencyInjection;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\BackendCompilerPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Alias;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\ContextProvidersPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\DependencySerializationTraitPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\GuzzleMiddlewarePass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Drupal\Core\DrupalKernelInterface;
@ -24,6 +19,7 @@ class ModifyServiceDefinitionsPass implements CompilerPassInterface {
if (!$container->has('kernel')) {
return;
}
$kernel = $container->get('kernel');
if (!($kernel instanceof DrupalKernelInterface)) {
return;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Drupal\Component\ProxyBuilder\ProxyBuilder;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -16,14 +11,13 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
class RegisterAccessChecksPass implements CompilerPassInterface {
/**
* Implements CompilerPassInterface::process().
*
* Adds services tagged 'access_check' to the access_manager service.
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) {
if (!$container->hasDefinition('access_manager')) {
return;
}
// Add services tagged 'access_check' to the access_manager service.
$access_manager = $container->getDefinition('access_manager.check_provider');
foreach ($container->findTaggedServiceIds('access_check') as $id => $attributes) {
$applies = array();
@ -43,4 +37,5 @@ class RegisterAccessChecksPass implements CompilerPassInterface {
$access_manager->addMethodCall('addCheckService', array($id, $method, $applies, $needs_incoming_request));
}
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterEventSubscribersPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -14,6 +9,10 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
* Registers all event subscribers to the event dispatcher.
*/
class RegisterEventSubscribersPass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) {
if (!$container->hasDefinition('event_dispatcher')) {
return;
@ -24,7 +23,8 @@ class RegisterEventSubscribersPass implements CompilerPassInterface {
$event_subscriber_info = [];
foreach ($container->findTaggedServiceIds('event_subscriber') as $id => $attributes) {
// We must assume that the class value has been correctly filled, even if the service is created by a factory
// We must assume that the class value has been correctly filled, even if
// the service is created by a factory.
$class = $container->getDefinition($id)->getClass();
$refClass = new \ReflectionClass($class);
@ -58,4 +58,5 @@ class RegisterEventSubscribersPass implements CompilerPassInterface {
$definition->addArgument($event_subscriber_info);
}
}

View file

@ -1,11 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterLazyRouteEnhancers.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,11 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterLazyRouteFilters.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -27,10 +22,10 @@ class RegisterServicesForDestructionPass implements CompilerPassInterface {
}
$definition = $container->getDefinition('kernel_destruct_subscriber');
$services = $container->findTaggedServiceIds('needs_destruction');
foreach ($services as $id => $attributes) {
$definition->addMethodCall('registerService', array($id));
}
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\RegisterStreamWrappersPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\StackedKernelPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Container.
*/
namespace Drupal\Core\DependencyInjection;
use Drupal\Component\DependencyInjection\Container as DrupalContainer;
@ -34,5 +29,4 @@ class Container extends DrupalContainer {
assert(FALSE, 'The container was serialized.');
return array_keys(get_object_vars($this));
}
}

View file

@ -1,16 +1,16 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ContainerBuilder.
*/
namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder as SymfonyContainerBuilder;
use Symfony\Component\DependencyInjection\Container as SymfonyContainer;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
/**
* Drupal's dependency injection container builder.
@ -21,6 +21,11 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
*/
class ContainerBuilder extends SymfonyContainerBuilder {
/**
* @var \Doctrine\Instantiator\InstantiatorInterface|null
*/
private $proxyInstantiator;
/**
* {@inheritdoc}
*/
@ -29,6 +34,161 @@ class ContainerBuilder extends SymfonyContainerBuilder {
parent::__construct($parameterBag);
}
/**
* Creates a service for a service definition.
*
* Overrides the parent implementation, but just changes one line about
* deprecations, see below.
*
* @param \Symfony\Component\DependencyInjection\Definition $definition
* @param string $id
* @param bool|true $tryProxy
*
* @return mixed|object
*/
public function createService(Definition $definition, $id, $tryProxy = true)
{
if ($definition->isSynthetic()) {
throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The DIC does not know how to construct this service.', $id));
}
if ($definition->isDeprecated()) {
// Suppress deprecation warnings when a service is marked as
// 'deprecated: %service_id%-no-warning'
if ($definition->getDeprecationMessage($id) != ($id . '-no-warning')) {
@trigger_error($definition->getDeprecationMessage($id), E_USER_DEPRECATED);
}
}
if ($tryProxy && $definition->isLazy()) {
$container = $this;
$proxy = $this
->getProxyInstantiator()
->instantiateProxy(
$container,
$definition,
$id, function () use ($definition, $id, $container) {
return $container->createService($definition, $id, false);
}
);
$this->shareService($definition, $proxy, $id);
return $proxy;
}
$parameterBag = $this->getParameterBag();
if (null !== $definition->getFile()) {
require_once $parameterBag->resolveValue($definition->getFile());
}
$arguments = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())));
if (null !== $factory = $definition->getFactory()) {
if (is_array($factory)) {
$factory = array($this->resolveServices($parameterBag->resolveValue($factory[0])), $factory[1]);
} elseif (!is_string($factory)) {
throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
}
$service = call_user_func_array($factory, $arguments);
if (!$definition->isDeprecated() && is_array($factory) && is_string($factory[0])) {
$r = new \ReflectionClass($factory[0]);
if (0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
@trigger_error(sprintf('The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.', $id, $r->name), E_USER_DEPRECATED);
}
}
} elseif (null !== $definition->getFactoryMethod(false)) {
if (null !== $definition->getFactoryClass(false)) {
$factory = $parameterBag->resolveValue($definition->getFactoryClass(false));
} elseif (null !== $definition->getFactoryService(false)) {
$factory = $this->get($parameterBag->resolveValue($definition->getFactoryService(false)));
} else {
throw new RuntimeException(sprintf('Cannot create service "%s" from factory method without a factory service or factory class.', $id));
}
$service = call_user_func_array(array($factory, $definition->getFactoryMethod(false)), $arguments);
} else {
$r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass()));
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments);
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
// Skip deprecation notices for deprecations which opt out.
@trigger_error(sprintf('The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name), E_USER_DEPRECATED);
}
}
if ($tryProxy || !$definition->isLazy()) {
// share only if proxying failed, or if not a proxy
$this->shareService($definition, $service, $id);
}
foreach ($definition->getMethodCalls() as $call) {
$this->callMethod($service, $call);
}
$properties = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getProperties())));
foreach ($properties as $name => $value) {
$service->$name = $value;
}
if ($callable = $definition->getConfigurator()) {
if (is_array($callable)) {
$callable[0] = $parameterBag->resolveValue($callable[0]);
if ($callable[0] instanceof Reference) {
$callable[0] = $this->get((string) $callable[0], $callable[0]->getInvalidBehavior());
} elseif ($callable[0] instanceof Definition) {
$callable[0] = $this->createService($callable[0], null);
}
}
if (!is_callable($callable)) {
throw new InvalidArgumentException(sprintf('The configure callable for class "%s" is not a callable.', get_class($service)));
}
call_user_func($callable, $service);
}
return $service;
}
/**
* Retrieves the currently set proxy instantiator or instantiates one.
*
* @return InstantiatorInterface
*/
private function getProxyInstantiator()
{
if (!$this->proxyInstantiator) {
$this->proxyInstantiator = new RealServiceInstantiator();
}
return $this->proxyInstantiator;
}
/**
* Direct copy of the parent function.
*/
protected function shareService(Definition $definition, $service, $id)
{
if ($definition->isShared() && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) {
if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) {
throw new InactiveScopeException($id, $scope);
}
$this->services[$lowerId = strtolower($id)] = $service;
if (self::SCOPE_CONTAINER !== $scope) {
$this->scopedServices[$scope][$lowerId] = $service;
}
}
}
/**
* Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set().
*

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ContainerInjectionInterface.
*/
namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ContainerNotInitializedException.
*/
namespace Drupal\Core\DependencyInjection;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\DependencySerializationTrait.
*/
namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -49,6 +44,10 @@ trait DependencySerializationTrait {
* {@inheritdoc}
*/
public function __wakeup() {
// Tests in isolation potentially unserialize in the parent process.
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP']) && !\Drupal::hasContainer()) {
return;
}
$container = \Drupal::getContainer();
foreach ($this->_serviceIds as $key => $service_id) {
$this->$key = $container->get($service_id);

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ServiceModifierInterface.
*/
namespace Drupal\Core\DependencyInjection;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ServiceProviderBase.
*/
namespace Drupal\Core\DependencyInjection;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ServiceProviderInterface.
*/
namespace Drupal\Core\DependencyInjection;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\YamlFileLoader.
*/
namespace Drupal\Core\DependencyInjection;
use Drupal\Component\FileCache\FileCacheFactory;
@ -159,8 +154,15 @@ class YamlFileLoader
$definition->setClass($service['class']);
}
if (isset($service['shared'])) {
$definition->setShared($service['shared']);
}
if (isset($service['scope'])) {
$definition->setScope($service['scope']);
if ('request' !== $id) {
@trigger_error(sprintf('The "scope" key of service "%s" in file "%s" is deprecated since version 2.8 and will be removed in 3.0.', $id, $file), E_USER_DEPRECATED);
}
$definition->setScope($service['scope'], false);
}
if (isset($service['synthetic'])) {
@ -183,6 +185,10 @@ class YamlFileLoader
$definition->setAbstract($service['abstract']);
}
if (array_key_exists('deprecated', $service)) {
$definition->setDeprecated(true, $service['deprecated']);
}
if (isset($service['factory'])) {
if (is_string($service['factory'])) {
if (strpos($service['factory'], ':') !== false && strpos($service['factory'], '::') === false) {
@ -275,7 +281,30 @@ class YamlFileLoader
if (isset($service['decorates'])) {
$renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null;
$definition->setDecoratedService($service['decorates'], $renameId);
$priority = isset($service['decoration_priority']) ? $service['decoration_priority'] : 0;
$definition->setDecoratedService($service['decorates'], $renameId, $priority);
}
if (isset($service['autowire'])) {
$definition->setAutowired($service['autowire']);
}
if (isset($service['autowiring_types'])) {
if (is_string($service['autowiring_types'])) {
$definition->addAutowiringType($service['autowiring_types']);
} else {
if (!is_array($service['autowiring_types'])) {
throw new InvalidArgumentException(sprintf('Parameter "autowiring_types" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
}
foreach ($service['autowiring_types'] as $autowiringType) {
if (!is_string($autowiringType)) {
throw new InvalidArgumentException(sprintf('A "autowiring_types" attribute must be of type string for service "%s" in %s. Check your YAML syntax.', $id, $file));
}
$definition->addAutowiringType($autowiringType);
}
}
}
$this->container->setDefinition($id, $definition);