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

Deprecate more service aliases #7010

Merged
merged 1 commit into from
Apr 2, 2021

Conversation

franmomu
Copy link
Member

@franmomu franmomu commented Apr 2, 2021

Subject

It should have been included in #7001

I am targeting this branch, because these changes are BC.

Changelog

### Deprecated
- Deprecated `Sonata\AdminBundle\Admin\AdminHelper` service alias.
- Deprecated `Sonata\AdminBundle\SonataConfiguration` service alias.

@franmomu franmomu added the minor label Apr 2, 2021
@franmomu franmomu marked this pull request as draft April 2, 2021 15:09
@franmomu franmomu force-pushed the deprecate_more_alias branch from b46cef5 to 005a1b9 Compare April 2, 2021 15:12
@franmomu franmomu changed the title Deprecate AdminHelper service alias Deprecate more service aliases Apr 2, 2021
@franmomu franmomu marked this pull request as ready for review April 2, 2021 15:16
@franmomu franmomu mentioned this pull request Apr 2, 2021
@VincentLanglet
Copy link
Member

How do you know that these one are not supposed to be in the public API ? But Pool or AdminObjectAclManipulator yes ?
I read #7000 but I dont understand.

@franmomu
Copy link
Member Author

franmomu commented Apr 2, 2021

How do you know that these one are not supposed to be in the public API ? But Pool or AdminObjectAclManipulator yes ?
I read #7000 but I dont understand.

I meant this part:

and aliases needed in case we use Service Subscribers (like CRUDController in 4.x).

In CRUDController we have:

public static function getSubscribedServices(): array
{
return [
'sonata.admin.pool' => Pool::class,
'sonata.admin.breadcrumbs_builder' => BreadcrumbsBuilderInterface::class,
'sonata.admin.audit.manager' => AuditManagerInterface::class,
'sonata.admin.object.manipulator.acl.admin' => AdminObjectAclManipulator::class,
'sonata.exporter.exporter' => '?'.Exporter::class,
'sonata.admin.admin_exporter' => '?'.AdminExporter::class,
'sonata.admin.security.acl_user_manager' => '?'.AdminAclUserManagerInterface::class,
'logger' => '?'.LoggerInterface::class,
'translator' => TranslatorInterface::class,
] + parent::getSubscribedServices();
}

The way it works is because it fetches the services that will be in the container from there, so those are the ones I was leaving (apart from the interfaces that I don't know if they are used).

Looking at the documentation we can maybe use https://symfony.com/doc/4.4/service_container/service_subscribers_locators.html#aliased-services and configure it through tags, I'll give it a try and we won't need anyone anymore I guess.

@franmomu
Copy link
Member Author

franmomu commented Apr 2, 2021

I haven't tried too much, but looks like using tags, you have to define also parent tags (the ones from AbstractController), that makes sense with the documentation: https://symfony.com/doc/4.4/service_container/service_subscribers_locators.html#including-services

When extending a class that also implements ServiceSubscriberInterface, it’s your responsibility to call the parent when overriding the method. This typically happens when extending AbstractController

So I think it's better if we leave it as it is.

@franmomu franmomu requested a review from a team April 2, 2021 16:23
@VincentLanglet VincentLanglet requested a review from a team April 2, 2021 17:26
@jordisala1991 jordisala1991 merged commit d2bc843 into sonata-project:3.x Apr 2, 2021
@jordisala1991
Copy link
Member

Thank you @franmomu

@franmomu franmomu deleted the deprecate_more_alias branch April 2, 2021 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants