Skip to content

Commit e40a695

Browse files
bennothommomjauvin
andauthored
Add Winter 1.2 support (#38)
Co-authored-by: Marc Jauvin <[email protected]>
1 parent 7f6258f commit e40a695

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

routes.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

3+
use Illuminate\Foundation\Application as Laravel;
34
use Winter\Translate\Models\Message;
45
use Winter\Translate\Classes\Translator;
56

67
/*
78
* Adds a custom route to check for the locale prefix.
89
*/
9-
App::before(function ($request) {
10+
$beforeCallback = function () {
1011
if (Config::get('winter.translate::disableLocalePrefixRoutes', false)) {
1112
return;
1213
}
@@ -43,12 +44,18 @@
4344
Route::any('{slug?}', 'Cms\Classes\CmsController@run')->where('slug', '(.*)?');
4445
});
4546
});
46-
});
47+
};
48+
49+
if (version_compare(Laravel::VERSION, '9.0.0', '>=')) {
50+
Event::listen('system.route', $beforeCallback);
51+
} else {
52+
App::before($beforeCallback);
53+
}
4754

4855
/*
4956
* Save any used messages to the contextual cache.
5057
*/
51-
App::after(function ($request) {
58+
App::after(function () {
5259
if (class_exists('Winter\Translate\Models\Message')) {
5360
Message::saveToCache();
5461
}

0 commit comments

Comments
 (0)