-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 acl_user_manager without implementing AdminAclUserManagerInterface #6480
Deprecate acl_user_manager without implementing AdminAclUserManagerInterface #6480
Conversation
if (null === $config['security']['acl_user_manager'] && isset($bundles['FOSUserBundle'])) { | ||
$container->setParameter('sonata.admin.security.acl_user_manager', 'fos_user.user_manager'); | ||
} else { | ||
$container->setParameter('sonata.admin.security.acl_user_manager', $config['security']['acl_user_manager']); | ||
} | ||
|
||
// NEXT_MAJOR: Uncomment this code. | ||
//if (null !== $config['security']['acl_user_manager']) { | ||
// $container->setAlias('sonata.admin.security.acl_user_manager', $config['security']['acl_user_manager']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take a look at my PR to see the correct alias, otherwise it does not work (at least on my tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also left this one because from the controller we are fetching it with get('sonata.admin.security.acl_user_manager')
SonataAdminBundle/src/DependencyInjection/SonataAdminExtension.php Lines 118 to 122 in 6d32a6f
IMO final class AclUserManager implement AdminAclUserManagerInterface
{
/**
* @var AdminAclUserManagerInterface
**/
private $manager;
public function __construct(?AdminAclUserManagerInterface $aclManager = null)
{
$this->manager = $manager;
}
public function findUsers(): ?\Traversable
{
if (null !== $this->manager) {
return $this->manager->findUsers();
}
return null;
}
}
->set('sonata.admin.security.acl_user_manager', AclUserManager::class)
->public()
->args([
'%sonata.admin.security.acl_user_manager%',
])
|
9e31b6f
to
6598a4c
Compare
I changed it a little bit, I think there is no need to create a class for that, the compiler pass can be removed in I've used the same strategy Symfony uses, for example with the They create an alias And then they create another alias |
/** | ||
* Batch configure the ACLs for all objects handled by an Admin. | ||
*/ | ||
public function findUsers(): \Traversable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt it better to use iterable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have use array
as return typehint ; like we did anywhere else in our code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When related to the persistence, we are starting to use Collection too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even when persistence are returning Collection
we're transforming them to array
https://github.com/sonata-project/SonataAdminBundle/blob/master/src/Datagrid/SimplePager.php#L68
If we start using iterable
which is not a bad idea, it's maybe better to change it too for others signatures ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, iterable
or array
seems better than \Traversable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left a minor comment, but it looks great to me
/** | ||
* Batch configure the ACLs for all objects handled by an Admin. | ||
*/ | ||
public function findUsers(): \Traversable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, iterable
or array
seems better than \Traversable
df4263d
to
8aa3d14
Compare
9105fd9
to
5c4e26e
Compare
Could you please rebase your PR and fix merge conflicts? |
5c4e26e
to
e45ac13
Compare
src/DependencyInjection/Compiler/CheckAclUserManagerCompilerPass.php
Outdated
Show resolved
Hide resolved
tests/DependencyInjection/Compiler/CheckAclUserManagerCompilerPassTest.php
Outdated
Show resolved
Hide resolved
…terface It also deprecates to not explicitly configuring acl_user_manager service when using ACL because if you use "friendsofsymfony/user-bundle", it adds "fos_user_manager" as "acl_user_manager" automatically. After this, this service MUST implements AdminAclUserManagerInterface allowing us to have an API for retrieving users when using ACL.
e45ac13
to
d14d872
Compare
|
||
$userManagerDefinition = $container->findDefinition($userManagerServiceName); | ||
|
||
if (!is_a($userManagerDefinition->getClass(), AdminAclUserManagerInterface::class, true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a warning: some time ago I added a similar check in our packages (I don't remember which one), and I had to add an extra DI resolution about the return value of Definition::getClass()
, since it can be also a parameter (by instance %admin.acl.user_manager.class%
) which must be resolved first in order to know the real class.
Thank you @franmomu |
Do you have the time to do the merge on master? I can handle the upgrade on master to remove next majors, after |
Subject
Ref: #6476 (comment)
The idea is introducing
AdminAclUserManagerInterface
which the service configured undersonata_admin.security.acl_user_manager
must implement. If it's ok, I'll add the upgrade note.I am targeting this branch, because these changes are BC.
Changelog
acl_user_manager
.