Skip to content

Commit

Permalink
fix: Command routes with {locale} in route
Browse files Browse the repository at this point in the history
  • Loading branch information
neznaika0 committed Nov 6, 2023
1 parent b951a15 commit ebc2643
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion system/Commands/Utilities/Routes/FilterFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use CodeIgniter\Filters\Filters;
use CodeIgniter\HTTP\Exceptions\RedirectException;
use CodeIgniter\Router\Router;
use Config\App;
use Config\Feature;
use Config\Services;

Expand Down Expand Up @@ -50,6 +51,12 @@ public function find(string $uri): array
{
$this->filters->reset();

$isLocaleExist = strpos($uri, '{locale}') !== false;

if ($isLocaleExist) {
$uri = str_replace('{locale}', config(App::class)->defaultLocale, $uri);
}

// Add route filters
try {
$routeFilters = $this->getRouteFilters($uri);
Expand All @@ -64,7 +71,14 @@ public function find(string $uri): array

$this->filters->initialize($uri);

return $this->filters->getFilters();
$filters = $this->filters->getFilters();

if ($isLocaleExist) {
$filters['before'] = array_map(static fn ($filter) => '!' . $filter, $filters['before']);
$filters['after'] = array_map(static fn ($filter) => '!' . $filter, $filters['after']);
}

return $filters;
} catch (RedirectException $e) {
return [
'before' => [],
Expand Down

0 comments on commit ebc2643

Please sign in to comment.