feature #23035 [3.4] Deprecate passing a concrete service in optional cache warmers (romainneutron)
This PR was merged into the 3.4 branch.
Discussion
----------
[3.4] Deprecate passing a concrete service in optional cache warmers
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks? | no
| Deprecations? | yes <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass? | yes
| Fixed tickets | N/A
| License | MIT
Commits
-------
b9c91cd
Deprecate passing a concrete service in optional cache warmers
This commit is contained in:
commit
9d24e80b00
@ -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
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriber
|
||||
/**
|
||||
* TranslationsCacheWarmer constructor.
|
||||
*
|
||||
* @param ContainerInterface|TranslatorInterface $container
|
||||
* @param ContainerInterface $container
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
@ -39,6 +39,7 @@ class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriber
|
||||
$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 Psr\Container\ContainerInterface as first argument.', __CLASS__));
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInte
|
||||
/**
|
||||
* TemplateCacheWarmer constructor.
|
||||
*
|
||||
* @param ContainerInterface|Environment $container
|
||||
* @param \Traversable $iterator
|
||||
* @param ContainerInterface $container
|
||||
* @param \Traversable $iterator
|
||||
*/
|
||||
public function __construct($container, \Traversable $iterator)
|
||||
{
|
||||
@ -41,6 +41,7 @@ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInte
|
||||
$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 Psr\Container\ContainerInterface as first argument.', __CLASS__));
|
||||
}
|
||||
|
Reference in New Issue
Block a user