Skip to content

Commit

Permalink
Append middleware to group instead of pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Friars committed Mar 6, 2024
1 parent 78b863f commit 251750b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ Whenever a model is transitioned out of the "published" state, changes to the mo
The package provides a middleware that can be enabled to toggle the visiblity of draft content in the application. This is useful for allowing specific users to preview draft content in a production environment.
You can disable the packages middleware and create your own by setting the `middleware.enabled` key to `false` in the configuration file.
You can disable the package's middleware and create your own by setting the `middleware.enabled` key to `false` in the configuration file.

If you are using the package's middleware, you can choose if you would like it to be enabled as global middleware or route middleware by setting the `middleware.global` key to `true` or `false` respectively.
If you are using the package's middleware, you can choose if you would like it to be enabled on a middleware group or as route middleware by setting the `middleware.group` key to the name of the group (ie: `web`) or `false` respectively.
 
Expand Down
2 changes: 1 addition & 1 deletion config/publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
'middleware' => [
'enabled' => true,
'global' => true,
'group' => false,
],
'urls' => [
'rewrite' => true,
Expand Down
4 changes: 2 additions & 2 deletions src/PublisherServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ protected function registerMiddleware(): self
return $this;
}

if (config('publisher.middleware.global') === true) {
if ($group = config('publisher.middleware.group')) {
$this->app->make(\Illuminate\Contracts\Http\Kernel::class)
->pushMiddleware(PublisherMiddleware::class);
->appendMiddlewareToGroup($group, PublisherMiddleware::class);
} else {
$this->app['router']->aliasMiddleware('publisher', PublisherMiddleware::class);
}
Expand Down

0 comments on commit 251750b

Please sign in to comment.