mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 23:06:08 -06:00
add SetLang params
This commit is contained in:
parent
bcc352f610
commit
84a071a82b
@ -10,6 +10,7 @@ use Visiosoft\AdvsModule\Adv\AdvRepository;
|
|||||||
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
||||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||||
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
||||||
|
use Visiosoft\AdvsModule\Http\Middleware\SetLang;
|
||||||
use Visiosoft\AdvsModule\Listener\AddAdvsSettingsScript;
|
use Visiosoft\AdvsModule\Listener\AddAdvsSettingsScript;
|
||||||
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||||
use Visiosoft\AdvsModule\Option\OptionRepository;
|
use Visiosoft\AdvsModule\Option\OptionRepository;
|
||||||
@ -231,7 +232,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
|||||||
* @type array|null
|
* @type array|null
|
||||||
*/
|
*/
|
||||||
protected $middleware = [
|
protected $middleware = [
|
||||||
//Visiosoft\AdvsModule\Http\Middleware\ExampleMiddleware::class
|
SetLang::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
<?php namespace Visiosoft\AdvsModule\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Redirector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SetLang
|
||||||
|
*/
|
||||||
|
class SetLang
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The redirect utility.
|
||||||
|
*
|
||||||
|
* @var Redirector
|
||||||
|
*/
|
||||||
|
protected $redirect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new SetLocale instance.
|
||||||
|
*
|
||||||
|
* @param Redirector $redirect
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
Redirector $redirect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->redirect = $redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($locale = $request->get('_setLang')) {
|
||||||
|
if ($locale) {
|
||||||
|
$request->session()->put('_locale', $locale);
|
||||||
|
} else {
|
||||||
|
$request->session()->remove('_locale');
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($request->has('redirect')) ? $this->redirect->to($request->get('redirect')) : $this->redirect->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user