-
Notifications
You must be signed in to change notification settings - Fork 14
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
The role instance is in charge of checking the permission type. #11
Conversation
@@ -38,13 +36,11 @@ public function __construct(TraversalStrategyInterface $strategy) | |||
* Determines if access is granted by checking the roles for permission. | |||
* | |||
* @param RoleInterface|RoleInterface[]|Traversable $roles | |||
* @param PermissionInterface|string $permission | |||
* @param PermissionInterface $permission |
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.
You must allow strings here, it'll receive string most of time, since currently ZfcRbac casts it to string before call Rbac::isGranted()
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 allow string in implementation. I just didn't know what to do with PermissionInterface in phpDoc.
I'll rewrite mixed
Your PR breaks BC a lot and makes things more strict. Some cases developer need to work with Permission entity rathen than a string. So, I'm 👎 Instead of it, I'd suggest is to accept |
Yes, that's what i wanted to do, but i did not dare remove the I'll rewrite with |
@@ -4,3 +4,4 @@ data/ | |||
vendor/ | |||
composer.lock | |||
composer.phar | |||
.idea |
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.
For PhpStorm
It was on purpose. I thought this project was for ZF3.
Keeping it just for the "string system". And because @bakura10 seems to want it. ;)
I'm not sure either, and frankly the "string system" is all i need. |
Hi, So. I'd say you guys are "right" regarding the removal of PermissionInterface, however I have one concern: the PermissionInterface job was mostly to enforce the __toString and avoid a lot of if ($permission instanceof PermissionInterface) {
$name = $permission->getName();
} else {
$name = (string) $permission;
} and to have better performance (__toString is much faster than a lot of conditionals). However, I agree that this should actually be left to the Role implementation to decide what to expect and what to do. BUT there are several places where this thing is actually useful:
Yes, this project is likely to be the Rbac component for ZF3. However it's used for ZfcRbac 2 so I need to keep BC. However no problem for opening an issue with various changes we could add for ZF3 when I'll make the PR. |
@bakura10 I agree, but fortunately that places are under |
@@ -12,7 +12,8 @@ | |||
use Rbac\Permission\PermissionInterface; | |||
|
|||
/** | |||
* Simple implementation for a role | |||
* Simple implementation for a role without hierarchy |
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.
It can fit in one line.
It's okay for everyone to merge this? ping @danizord and @arekkas. In turn I'll be able to merge this one: ZF-Commons/zfc-rbac#183 I think the potential of BC is really small on this one. What do you think? |
Well what doesn't really makes sense to me is that the Role implementation is dependent on an interface but the Interface, the role implements, is not. So imho: either remove it completely or keep it in the RoleInterface as well. Regarding ZfcRbac: If a PermissionInterface with __toString is required, why not provide it via the ZfcRbac namespace? I think it doesn't make much sense to keep the Interface here only because it is needed in ZfcRbac |
Completely agree that the permission interface should be moved to ZfcRbac. Actually this can be done without any BC by deprecating it on rbac side, and creating it on ZfcRbac where the ZfcRbac permission interface extends the Rbac one. Envoyé de mon iPhone
|
Yeah, 👍 let's move it to ZfcRbac. |
The role instance is in charge of checking the permission type.
I just realized @jmleroux that Role has not been updated and still references PermissionInterface: http://github.com/zf-fr/rbac/blob/master/src/Rbac/Role/Role.php How do you deal with this? |
Indeed, this is a problem. |
Just silently remove the interface from docblocks and keep the |
But what's the point of casting if we do not enforce a PermissionInterface. If we have "mixed" then we cannot cast to string because it may be na object that do not have any __toString defined. You see, the interface was actually useful :/. |
@bakura10 The |
Most of time developers will write their own implementation of |
Another try to resove #9 and #10.
I keep
PermissionInterface
but it should be removed...