Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setDeprecated deprecation #379

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -48,12 +49,23 @@ private function aliasRenamedServices(ContainerBuilder $container): void
{
if ($container->hasDefinition('pagerfanta.twig_extension')) {
$container->setAlias('twig.extension.pagerfanta', 'pagerfanta.twig_extension')
->setDeprecated(true, 'The "%alias_id%" service alias is deprecated since Sylius 1.8, use the "pagerfanta.twig_extension" service ID instead.');
->setDeprecated(...$this->getDeprecationMessage());
}

if ($container->hasDefinition('pagerfanta.view_factory')) {
$container->setAlias('white_october_pagerfanta.view_factory', 'pagerfanta.view_factory')
->setDeprecated(true, 'The "%alias_id%" service alias is deprecated since Sylius 1.8, use the "pagerfanta.view_factory" service ID instead.');
->setDeprecated(...$this->getDeprecationMessage());
}
}

private function getDeprecationMessage(): array
{
$message = 'The "%alias_id%" service alias is deprecated since Sylius 1.8, use the "pagerfanta.view_factory" service ID instead.';

if (method_exists(Alias::class, 'getDeprecation')) {
Copy link
Member

@lchrusciel lchrusciel Apr 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be better to base it on Symfony version? Also, can we see, that it really makes a change in some CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getDeprecation method is added in the same PR, see symfony/symfony#35778. So i think this should be good enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it, I have the problem, that checking the number of arguments or Symfony version is a more explicit check for me. But perhaps, I'm just picky

return ['sylius/resource-bundle', '1.8', $message];
}

return [$message];
}
}