coopTilleuls / CoopTilleulsAclSonataAdminExtensionBundle

ACL list filtering for SonataAdmin
http://les-tilleuls.coop
MIT License
45 stars 21 forks source link

Update services.xml #21

Closed vedro-compota closed 7 years ago

vedro-compota commented 7 years ago

Use security.token_storage for Symfony 3.2.6+

meyerbaptiste commented 7 years ago

Hi @vedro-compota, this is a good catch, thx.

But first, can you group your 2 PRs please?

Then, the current minimum version supported for symfony/security and symfony/security-bundle is v2.2.0 because of our support of sonata-project/admin-bundle v2.2.2 and its dependencies. So, we need to keep a compatibility with the security.context service and the SecurityContextInterface interface. They were deprecated in the v2.6.0 and deleted in the v3.0.0.

IMO the good way to do this is to test if the TokenStorageInterface interface exists and to inject the correct service in the CoopTilleulsAclSonataAdminExtensionExtension::load() method. Then remove the type-hinting in the definition of the AclAdminExtension::__construct() method for the $securityContext parameter. Then test inside the constructor if $securityContext is an instance of TokenStorageInterface or SecurityContextInterface. If not, throw an InvalidArgumentException.

vedro-compota commented 7 years ago

Hi, @meyerbaptiste :) but what about line:

<argument type="service" id="security.token_storage" />

in CoopTilleulsAclSonataAdminExtensionBundle/Resources/config/services.xml config file? What is the best way to proceed?

meyerbaptiste commented 7 years ago

You can keep the argument empty: <argument />.

Inside the CoopTilleulsAclSonataAdminExtensionExtension::load() method test if the TokenStorageInterface interface exists. If true, create a new Reference instance with the security.token_storage service or if false, with the security.context service. Then, use the Definition::replaceArgument() method to inject the correct reference in our coop_tilleuls_acl_sonata_admin_extension.acl.extension service definition.

http://symfony.com/doc/current/service_container/definitions.html

vedro-compota commented 7 years ago

@meyerbaptiste please check changes)

meyerbaptiste commented 7 years ago

Thank you very much @vedro-compota 👍

vedro-compota commented 7 years ago

Thank you @meyerbaptiste for your big help! 😊