Skip to content

Commit cc3c08d

Browse files
committed
Deprecate passing a concrete service in optional cache warmers
1 parent 068f8d1 commit cc3c08d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* Generates the catalogues for translations.
2121
*
2222
* @author Xavier Leune <xavier.leune@gmail.com>
23+
*
24+
* @final since version 3.4, to be given a container instead in 4.0
2325
*/
2426
class TranslationsCacheWarmer implements CacheWarmerInterface
2527
{
@@ -29,7 +31,7 @@ class TranslationsCacheWarmer implements CacheWarmerInterface
2931
/**
3032
* TranslationsCacheWarmer constructor.
3133
*
32-
* @param ContainerInterface|TranslatorInterface $container
34+
* @param ContainerInterface $container
3335
*/
3436
public function __construct($container)
3537
{
@@ -38,8 +40,9 @@ public function __construct($container)
3840
$this->container = $container;
3941
} elseif ($container instanceof TranslatorInterface) {
4042
$this->translator = $container;
43+
@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);
4144
} else {
42-
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Symfony\Component\Translation\TranslatorInterface as first argument.', __CLASS__));
45+
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface as first argument.', __CLASS__));
4346
}
4447
}
4548

src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* Generates the Twig cache for all templates.
2121
*
2222
* @author Fabien Potencier <fabien@symfony.com>
23+
*
24+
* @final since version 3.4, to be given a container instead in 4.0
2325
*/
2426
class TemplateCacheWarmer implements CacheWarmerInterface
2527
{
@@ -30,8 +32,8 @@ class TemplateCacheWarmer implements CacheWarmerInterface
3032
/**
3133
* TemplateCacheWarmer constructor.
3234
*
33-
* @param ContainerInterface|Environment $container
34-
* @param \Traversable $iterator
35+
* @param ContainerInterface $container
36+
* @param \Traversable $iterator
3537
*/
3638
public function __construct($container, \Traversable $iterator)
3739
{
@@ -40,8 +42,9 @@ public function __construct($container, \Traversable $iterator)
4042
$this->container = $container;
4143
} elseif ($container instanceof Environment) {
4244
$this->twig = $container;
45+
@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);
4346
} else {
44-
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Environment as first argument.', __CLASS__));
47+
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface as first argument.', __CLASS__));
4548
}
4649

4750
$this->iterator = $iterator;

0 commit comments

Comments
 (0)