Skip to content

Commit

Permalink
Remove no longer necessary config file
Browse files Browse the repository at this point in the history
  • Loading branch information
doefom committed May 30, 2024
1 parent 2feff47 commit f807efd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
5 changes: 0 additions & 5 deletions config/restrict.php

This file was deleted.

22 changes: 0 additions & 22 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@ public function register(): void

public function bootAddon(): void
{
// ------------------------------------------------------------------------------------
// Register the config file
// ------------------------------------------------------------------------------------

$this->publishes([
__DIR__.'/../config/restrict.php' => config_path('restrict.php'),
], 'restrict-config');

// ------------------------------------------------------------------------------------
// Try to bind the configured policy
// ------------------------------------------------------------------------------------

$entryPolicy = config('restrict.entry_policy');

if (! $entryPolicy) {
Log::warning('Restrict addon (doefom/restrict) is installed but no entry policy is configured. Please configure an entry policy in the restrict.php config file.');

return;
}

$this->app->bind(EntryPolicy::class, $entryPolicy);

// ------------------------------------------------------------------------------------
// Bind the entry query builder
// ------------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions src/Stache/Query/EntryQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ protected function getFilteredKeys()

$entryPolicy = app(EntryPolicy::class);

if (get_class($entryPolicy) === EntryPolicy::class) {
// No custom policy is defined, so we don't need to filter the keys.
return $resKeys;
}

return $resKeys->filter(function ($key) use ($user, $entryPolicy) {
$entry = $this->store->getItem($key);

Expand Down

0 comments on commit f807efd

Please sign in to comment.