Deprecate passing a concrete service in optional cache warmers

This commit is contained in:
Romain Neutron 2017-06-02 15:07:31 +02:00
parent 068f8d1341
commit b9c91cd88c
No known key found for this signature in database
GPG Key ID: 201FC7CF9F0CA3ED
3 changed files with 9 additions and 5 deletions

View File

@ -19,6 +19,8 @@ use Symfony\Component\Routing\RouterInterface;
* Generates the router matcher and generator classes.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since version 3.4, to be given a container instead in 4.0
*/
class RouterCacheWarmer implements CacheWarmerInterface
{

View File

@ -29,7 +29,7 @@ class TranslationsCacheWarmer implements CacheWarmerInterface
/**
* TranslationsCacheWarmer constructor.
*
* @param ContainerInterface|TranslatorInterface $container
* @param ContainerInterface $container
*/
public function __construct($container)
{
@ -38,8 +38,9 @@ class TranslationsCacheWarmer implements CacheWarmerInterface
$this->container = $container;
} elseif ($container instanceof TranslatorInterface) {
$this->translator = $container;
@trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since version 3.4 and will be unsupported in version 4.0. Use a %s instead.', TranslatorInterface::class, __CLASS__, ContainerInterface::class), E_USER_DEPRECATED);
} else {
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Symfony\Component\Translation\TranslatorInterface as first argument.', __CLASS__));
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface as first argument.', __CLASS__));
}
}

View File

@ -30,8 +30,8 @@ class TemplateCacheWarmer implements CacheWarmerInterface
/**
* TemplateCacheWarmer constructor.
*
* @param ContainerInterface|Environment $container
* @param \Traversable $iterator
* @param ContainerInterface $container
* @param \Traversable $iterator
*/
public function __construct($container, \Traversable $iterator)
{
@ -40,8 +40,9 @@ class TemplateCacheWarmer implements CacheWarmerInterface
$this->container = $container;
} elseif ($container instanceof Environment) {
$this->twig = $container;
@trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since version 3.4 and will be unsupported in version 4.0. Use a %s instead.', Environment::class, __CLASS__, Container::class), E_USER_DEPRECATED);
} else {
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Environment as first argument.', __CLASS__));
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface as first argument.', __CLASS__));
}
$this->iterator = $iterator;