Closed vedro-compota closed 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
.
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?
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
@meyerbaptiste please check changes)
Thank you very much @vedro-compota 👍
Thank you @meyerbaptiste for your big help! 😊
Use security.token_storage for Symfony 3.2.6+