Skip to content

Commit

Permalink
Make boot method fluent
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Nov 27, 2023
1 parent 5c4b282 commit af1fc1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/Auth/CorePermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ protected function registerForms()

protected function registerUtilities()
{
Utility::boot();

Utility::all()->each(function ($utility) {
Utility::boot()->all()->each(function ($utility) {
Permission::register("access {$utility->handle()} utility", function ($perm) use ($utility) {
return $perm
->label(__('statamic::permissions.access_utility', ['title' => $utility->title()]))
Expand Down
6 changes: 3 additions & 3 deletions src/CP/Utilities/UtilityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function boot()
foreach ($this->extensions as $callback) {
$callback($this);
}

return $this;
}

public function extend($callback)
Expand Down Expand Up @@ -70,10 +72,8 @@ public function findBySlug($slug)

public function routes()
{
$this->boot();

Route::namespace('\\')->prefix('utilities')->name('utilities.')->group(function () {
$this->all()->each(function ($utility) {
$this->boot()->all()->each(function ($utility) {
if ($utility->action()) {
Route::get($utility->slug(), $utility->action())
->middleware("can:access {$utility->handle()} utility")
Expand Down

0 comments on commit af1fc1f

Please sign in to comment.