From d414ee33ed7f9455d1931800091e133561f06f7b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Wed, 1 Jul 2015 16:49:40 +0930 Subject: [PATCH] Make traits more generic Type hinting User should take place in the callbacks. Theoretically these traits could be used for another project now, where something else has permissions (like a Sheep class, or a number) --- src/Core/Support/Locked.php | 8 +++----- src/Core/Support/VisibleScope.php | 6 ++---- src/Extend/Model.php | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Core/Support/Locked.php b/src/Core/Support/Locked.php index 4d0cbd8a9..628e59bcb 100644 --- a/src/Core/Support/Locked.php +++ b/src/Core/Support/Locked.php @@ -1,8 +1,6 @@ getConditions($action) as $condition) { $can = $condition($this, $user, $action); @@ -48,7 +46,7 @@ trait Locked * * @throws \Flarum\Core\Exceptions\PermissionDeniedException */ - public function assertCan(User $user, $action) + public function assertCan($user, $action) { if (! $this->can($user, $action)) { throw new PermissionDeniedException; diff --git a/src/Core/Support/VisibleScope.php b/src/Core/Support/VisibleScope.php index cbe1a5b21..a0c5a3d70 100644 --- a/src/Core/Support/VisibleScope.php +++ b/src/Core/Support/VisibleScope.php @@ -1,17 +1,15 @@ scopeVisible as $callback) { - $model::scopeVisible($callback); + $model::addVisiblePostsScope($callback); } foreach ($this->allow as $info) {