Skip to content

Commit

Permalink
Add Winter 1.2 support (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Jauvin <[email protected]>
bennothommo and mjauvin authored Jul 18, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 7f6258f commit e40a695
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions routes.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

use Illuminate\Foundation\Application as Laravel;
use Winter\Translate\Models\Message;
use Winter\Translate\Classes\Translator;

/*
* Adds a custom route to check for the locale prefix.
*/
App::before(function ($request) {
$beforeCallback = function () {
if (Config::get('winter.translate::disableLocalePrefixRoutes', false)) {
return;
}
@@ -43,12 +44,18 @@
Route::any('{slug?}', 'Cms\Classes\CmsController@run')->where('slug', '(.*)?');
});
});
});
};

if (version_compare(Laravel::VERSION, '9.0.0', '>=')) {
Event::listen('system.route', $beforeCallback);
} else {
App::before($beforeCallback);
}

/*
* Save any used messages to the contextual cache.
*/
App::after(function ($request) {
App::after(function () {
if (class_exists('Winter\Translate\Models\Message')) {
Message::saveToCache();
}

0 comments on commit e40a695

Please sign in to comment.