diff --git a/src/Http/Controllers/StatamicRewriteController.php b/src/Http/Controllers/StatamicRewriteController.php deleted file mode 100644 index c9a7465..0000000 --- a/src/Http/Controllers/StatamicRewriteController.php +++ /dev/null @@ -1,30 +0,0 @@ -get('rapidez.store_code'); - - $entry = Entry::query() - ->where('collection', 'pages') - ->where('locale', $storeCode) - ->where('slug', $request->path() == '/' ? 'home' : $request->path()) - ->first(); - - if (!$entry) { - throw new NotFoundHttpException(); - } - - $template = View::exists($entry->template()) ? $entry->template() : $entry->blueprint->handle(); - - echo view($template, ['entry' => $entry]); - } -} diff --git a/src/Http/StatamicDataComposer.php b/src/Http/ViewComposers/StatamicDataComposer.php similarity index 94% rename from src/Http/StatamicDataComposer.php rename to src/Http/ViewComposers/StatamicDataComposer.php index 31b92f2..f4eaa66 100644 --- a/src/Http/StatamicDataComposer.php +++ b/src/Http/ViewComposers/StatamicDataComposer.php @@ -1,6 +1,7 @@ bootConfig() ->bootRepositories() ->bootPublishables() - ->bootFilters() ->bootComposers() - ->bootListeners(); + ->bootListeners() + ->bootRoutes(); } - public function bootConfig() : self + public function bootRoutes() : self { - $this->mergeConfigFrom(__DIR__.'/../config/statamic.php', 'statamic'); + if (!$this->app->routesAreCached()) { + Rapidez::addFallbackRoute([FrontendController::class, 'index'], 100); + } return $this; } - public function bootFilters() : self + public function bootConfig() : self { - Eventy::addFilter('routes', fn ($routes) => array_merge($routes ?: [], [__DIR__.'/../routes/fallback.php'])); + $this->mergeConfigFrom(__DIR__.'/../config/statamic.php', 'statamic'); return $this; } - public function bootCommands() : self { $this->commands([