Skip to content

Commit

Permalink
Ability to remove fallback routes (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning authored Feb 3, 2023
1 parent 2bfff65 commit 9206ad8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Facades/Rapidez.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* @method static self addFallbackRoute($action, $position = 9999)
* @method static self removeFallbackRoute($action)
* @method static Collection getAllFallbackRoutes()
* @method static ?string config(string $path, $default = null, bool $sensitive = false)
* @method static ?string content($content)
Expand Down
8 changes: 8 additions & 0 deletions src/Rapidez.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public function addFallbackRoute($action, $position = 9999)
return $this;
}

public function removeFallbackRoute($action)
{
$action = RouteAction::parse('', $action);
$this->routes = $this->routes->reject(fn ($route) => $route['action'] === $action);

return $this;
}

public function getAllFallbackRoutes()
{
return $this->routes->sortBy('position');
Expand Down

0 comments on commit 9206ad8

Please sign in to comment.