Commit 4c30de36 authored by catch's avatar catch

Issue #2726645 by klausi: Do not @deprecate EntityManager until all usages are...

Issue #2726645 by klausi: Do not @deprecate EntityManager until all usages are removed (helps the Symfony 3 update)
parent 445bc901
......@@ -504,10 +504,13 @@ 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:
# 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
deprecated: '%service_id%-no-warning'
# @todo Remove this tag in https://www.drupal.org/node/2549143.
tags:
- { name: plugin_manager_cache_clear }
......
......@@ -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.
......@@ -35,129 +31,6 @@ public function __construct(ParameterBagInterface $parameterBag = NULL) {
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.
*
......
......@@ -10,7 +10,9 @@
/**
* Provides a wrapper around many other services relating to entities.
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. We cannot
* use the deprecated PHPDoc tag because this service class is still used in
* legacy code paths. Symfony would fail test cases with deprecation warnings.
*
* @todo Enforce the deprecation of each method once
* https://www.drupal.org/node/2578361 is in.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment