diff --git a/core/core.services.yml b/core/core.services.yml index cc4b8bc..7d38991 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -504,10 +504,11 @@ services: theme_installer: class: Drupal\Core\Extension\ThemeInstaller arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state'] + # @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use the other + # entity* services instead. entity.manager: - # This service is deprecated. We cannot set the deprecated property here - # because many test cases still rely on this service and they would fail - # with PHP deprecated warnings. + # We cannot set the deprecated property here because many test cases still + # rely on this service and they would fail with deprecation warnings. class: Drupal\Core\Entity\EntityManager parent: container.trait # @todo Remove this tag in https://www.drupal.org/node/2549143. diff --git a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php index 8708e36..f758e0d 100644 --- a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -157,6 +157,8 @@ public function getListeners($event_name = NULL) { * {@inheritdoc} */ public function getListenerPriority($eventName, $listener) { + // Parts copied from \Symfony\Component\EventDispatcher, that's why you see + // a yoda condition here. if (!isset($this->listeners[$eventName])) { return; } @@ -170,6 +172,8 @@ public function getListenerPriority($eventName, $listener) { foreach ($definitions as $key => &$definition) { if (!isset($definition['callable'])) { + // Once the callable is retrieved we keep it for subsequent method + // invocations on this class. $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]]; if ($definition['callable'] === $listener) { return $priority; diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index 8495b77..3e2d92d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -7,11 +7,7 @@ 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. @@ -36,119 +32,6 @@ public function __construct(ParameterBagInterface $parameterBag = NULL) { } /** - * 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); - } - } - } 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 diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 750e77a..a11939b 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -10,9 +10,7 @@ /** * Provides a wrapper around many other services relating to entities. * - * Deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. We cannot - * use the deprecated PHPDoc tag because then Symfony 3 would fail test cases - * with PHP deprecated warnings. + * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. * * @todo Enforce the deprecation of each method once * https://www.drupal.org/node/2578361 is in.