CRUDlex\ControllerProvider::setLocale PHP Method

setLocale() public method

The controller for setting the locale.
public setLocale ( Request $request, Silex\Application $app, string $locale ) : Response
$request Symfony\Component\HttpFoundation\Request the current request
$app Silex\Application the Silex application
$locale string the new locale
return Symfony\Component\HttpFoundation\Response redirects to the instance details page or 404 on invalid input
    public function setLocale(Request $request, Application $app, $locale)
    {
        if (!in_array($locale, $app['crud']->getLocales())) {
            return $this->getNotFoundPage($app, 'Locale ' . $locale . ' not found.');
        }
        if ($app['crud']->isManagingI18n()) {
            $app['session']->set('locale', $locale);
        }
        $redirect = $request->get('redirect');
        return $app->redirect($redirect);
    }