-
-
Notifications
You must be signed in to change notification settings - Fork 826
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
WIP Policy Refactor, Extender #2056
Conversation
0aa38bb
to
21cb324
Compare
… scopeModelVisibility to use that singleton
… just viewing instances in a query
21cb324
to
6078a0d
Compare
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. |
Not stale. |
public static $ALLOW = 'ALLOW'; | ||
public static $DENY = 'DENY'; | ||
public static $FORCE_ALLOW = 'FORCE_ALLOW'; | ||
public static $FORCE_DENY = 'FORCE_DENY'; |
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.
are these meant to be constants ? if so let's declare them as such:
public const ALLOW = 'ALLOW';
public const DENY = 'DENY';
public const FORCE_ALLOW = 'FORCE_ALLOW';
public const FORCE_DENY = 'FORCE_DENY';
* @deprecated in favor of checkAbility | ||
*/ | ||
public function getPermission(GetPermission $event) | ||
{ |
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.
If this is deprecated, why don't we just call checkAbility
from here, instead of having duplicated blocks of code.
* @param ScopeModelVisibility $event | ||
* @deprecated | ||
*/ | ||
public function scopeModelVisibility(ScopeModelVisibility $event) | ||
{ |
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.
same here, why not just call scopeQueryListener
|
||
$results = []; | ||
foreach ($this->app->make('flarum.policies') as $policy) { | ||
$results[] = $this->app->make($policy)->checkAbility($actor, $ability, $model); |
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.
Before this refactor, when policies were listeners, they were resolved only once.
How about we resolve them all in an array before making the gate and then we use that array of all resolved policies inside.
Foundation for fixing #1832
Part of #1891
Changes proposed in this pull request:
Reviewers should focus on:
TODO
If this is accepted and merged, bundled extensions will need to be updated.
Confirmed
composer test
).