<commit_before><?php
namespace Czim\CmsModels\Http\Middleware;

use Closure;
use Czim\CmsModels\Contracts\Support\Translation\TranslationLocaleHelperInterface;
use Czim\CmsModels\Http\Controllers\DefaultModelController;

class StoreActiveFormContext
{

    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param Closure                  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $this->storeActiveTranslationLocale();

        return $next($request);
    }

    /**
     * Stores active translation locale in session.
     */
    protected function storeActiveTranslationLocale()
    {
        $locale = request()->input(DefaultModelController::ACTIVE_TRANSLATION_LOCALE_KEY);

        if ( ! $locale) return;

        /** @var TranslationLocaleHelperInterface $helper */
        $helper = app(TranslationLocaleHelperInterface::class);

        $helper->setActiveLocale($locale);
    }

}<commit_msg>Cleaned up middleware class<commit_after><?php
namespace Czim\CmsModels\Http\Middleware;

use Closure;
use Czim\CmsModels\Contracts\Support\Translation\TranslationLocaleHelperInterface;
use Czim\CmsModels\Http\Controllers\DefaultModelController;

class StoreActiveFormContext
{

    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param Closure                  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $this->storeActiveTranslationLocale($request);

        return $next($request);
    }

    /**
     * Stores active translation locale in session.
     *
     * @param \Illuminate\Http\Request $request
     */
    protected function storeActiveTranslationLocale($request)
    {
        $locale = $request->input(DefaultModelController::ACTIVE_TRANSLATION_LOCALE_KEY);

        if ( ! $locale) return;

        /** @var TranslationLocaleHelperInterface $helper */
        $helper = app(TranslationLocaleHelperInterface::class);

        $helper->setActiveLocale($locale);
    }

}
{'fraction_non_alphanumeric': 0.1062618595825427, 'fraction_numerical': 0.0, 'mean_word_length': 3.0095057034220534, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7581170', 'n_tokens_mistral': 579, 'n_tokens_neox': 573, 'n_words': 108}