Skip to content

Commit

Permalink
Consistently call magic permission methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Dec 22, 2024
1 parent 3ca5f87 commit 7d6756a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/areas/site/buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions src/Cms/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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();
}

/**
Expand All @@ -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();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Cms/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -757,15 +757,15 @@ 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();
}

/**
* Checks if the page is sortable
*/
public function isSortable(): bool
{
return $this->permissions()->can('sort');
return $this->permissions()->sort();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Cms/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function canBeChanged(): static
'role' => $role->id()
]);

return $newUser->permissions()->can('changeRole');
return $newUser->permissions()->changeRole();
});
}

Expand All @@ -72,7 +72,7 @@ public function canBeCreated(): static
'role' => $role->id()
]);

return $newUser->permissions()->can('create');
return $newUser->permissions()->create();
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cms/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit 7d6756a

Please sign in to comment.