From 7d6756ac1e25894dfe9315b69477f839bd9d64e0 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Sun, 22 Dec 2024 20:32:34 +0100 Subject: [PATCH] Consistently call magic permission methods --- config/areas/site/buttons.php | 2 +- src/Cms/File.php | 6 +++--- src/Cms/Page.php | 8 ++++---- src/Cms/Roles.php | 4 ++-- src/Cms/User.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/areas/site/buttons.php b/config/areas/site/buttons.php index 575148af5c..e2e1779a67 100644 --- a/config/areas/site/buttons.php +++ b/config/areas/site/buttons.php @@ -17,7 +17,7 @@ ); }, 'page.preview' => function (Page $page) { - if ($page->permissions()->can('preview') === true) { + if ($page->permissions()->preview() === true) { return new PreviewDropdownButton( open: $page->previewUrl(), preview: $page->panel()->url(true) . '/preview/compare', diff --git a/src/Cms/File.php b/src/Cms/File.php index 4e6b75ce3f..0c5a346306 100644 --- a/src/Cms/File.php +++ b/src/Cms/File.php @@ -323,7 +323,7 @@ public function isAccessible(): bool $template = $this->template() ?? '__none__'; $accessible[$role] ??= []; - return $accessible[$role][$template] ??= $this->permissions()->can('access'); + return $accessible[$role][$template] ??= $this->permissions()->access(); } /** @@ -347,7 +347,7 @@ public function isListable(): bool $template = $this->template() ?? '__none__'; $listable[$role] ??= []; - return $listable[$role][$template] ??= $this->permissions()->can('list'); + return $listable[$role][$template] ??= $this->permissions()->list(); } /** @@ -362,7 +362,7 @@ public function isReadable(): bool $template = $this->template() ?? '__none__'; $readable[$role] ??= []; - return $readable[$role][$template] ??= $this->permissions()->can('read'); + return $readable[$role][$template] ??= $this->permissions()->read(); } /** diff --git a/src/Cms/Page.php b/src/Cms/Page.php index 766369c81e..5ad56c5df3 100644 --- a/src/Cms/Page.php +++ b/src/Cms/Page.php @@ -527,7 +527,7 @@ public function isAccessible(): bool $template = $this->intendedTemplate()->name(); $accessible[$role] ??= []; - return $accessible[$role][$template] ??= $this->permissions()->can('access'); + return $accessible[$role][$template] ??= $this->permissions()->access(); } /** @@ -699,7 +699,7 @@ public function isListable(): bool $template = $this->intendedTemplate()->name(); $listable[$role] ??= []; - return $listable[$role][$template] ??= $this->permissions()->can('list'); + return $listable[$role][$template] ??= $this->permissions()->list(); } /** @@ -757,7 +757,7 @@ public function isReadable(): bool $template = $this->intendedTemplate()->name(); $readable[$role] ??= []; - return $readable[$role][$template] ??= $this->permissions()->can('read'); + return $readable[$role][$template] ??= $this->permissions()->read(); } /** @@ -765,7 +765,7 @@ public function isReadable(): bool */ public function isSortable(): bool { - return $this->permissions()->can('sort'); + return $this->permissions()->sort(); } /** diff --git a/src/Cms/Roles.php b/src/Cms/Roles.php index 5feda70c60..c1d237d8a7 100644 --- a/src/Cms/Roles.php +++ b/src/Cms/Roles.php @@ -46,7 +46,7 @@ public function canBeChanged(): static 'role' => $role->id() ]); - return $newUser->permissions()->can('changeRole'); + return $newUser->permissions()->changeRole(); }); } @@ -72,7 +72,7 @@ public function canBeCreated(): static 'role' => $role->id() ]); - return $newUser->permissions()->can('create'); + return $newUser->permissions()->create(); }); } diff --git a/src/Cms/User.php b/src/Cms/User.php index 62b0398b65..3eb6868b0b 100644 --- a/src/Cms/User.php +++ b/src/Cms/User.php @@ -583,7 +583,7 @@ public function roles(): Roles // if the authenticated user doesn't have the permission to change // the role of this user, only the current role is available - if ($this->permissions()->can('changeRole') === false) { + if ($this->permissions()->changeRole() === false) { return $roles->filter('id', $this->role()->id()); }