Skip to content

Commit

Permalink
Refactored routing (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobWez98 authored Dec 1, 2022
1 parent 9d95031 commit 6e12c6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 41 deletions.
30 changes: 0 additions & 30 deletions src/Http/Controllers/StatamicRewriteController.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace Rapidez\Statamic\Http;
namespace Rapidez\Statamic\Http\ViewComposers;

use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
use Statamic\Facades\GlobalSet;
Expand Down
21 changes: 11 additions & 10 deletions src/RapidezStatamicServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
namespace Rapidez\Statamic;

use Illuminate\Support\ServiceProvider;
use TorMorten\Eventy\Facades\Eventy;

use Statamic\Http\Controllers\FrontendController;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
use Rapidez\Statamic\Commands\SyncProductsCommand;
use Rapidez\Statamic\Commands\SyncCategoriesCommand;
use Statamic\Facades\Entry;
use Statamic\Stache\Repositories\EntryRepository as StatamicEntryRepository;
use Rapidez\Statamic\Repositories\EntryRepository;
use Rapidez\Statamic\Http\StatamicDataComposer;
use Rapidez\Statamic\Http\ViewComposers\StatamicDataComposer;
use Statamic\Statamic;
use Illuminate\Support\Facades\View;
use Illuminate\View\View as RenderedView;
use Statamic\Facades\Site;
use Rapidez\Core\Facades\Rapidez;
use Validator;
use Statamic\Events\GlobalSetSaved;
use Statamic\Events\GlobalSetDeleted;
Expand All @@ -31,26 +31,27 @@ public function boot()
->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([
Expand Down

0 comments on commit 6e12c6c

Please sign in to comment.