<commit_before><?php

namespace Knp\DoctrineBehaviors\ORM\Translatable;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\Container;

/**
 * @author     <NAME> <<EMAIL>>
 */
class CurrentLocaleCallable
{
    private $container;

    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    public function __invoke()
    {
        $request = $this->container->get('request');

        return $request->getLocale() ?: $request->getDefaultLocale();
    }
}
<commit_msg>[translatable] fix inactive request scope problem for locale detection<commit_after><?php

namespace Knp\DoctrineBehaviors\ORM\Translatable;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\Container;

/**
 * @author     <NAME> <<EMAIL>>
 */
class CurrentLocaleCallable
{
    private $container;

    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    public function __invoke()
    {
        if (!$this->container->isScopeActive('request')) {
            return;
        }

        $request = $this->container->get('request');

        return $request->getLocale() ?: $request->getDefaultLocale();
    }
}

{'fraction_non_alphanumeric': 0.13126491646778043, 'fraction_numerical': 0.0, 'mean_word_length': 3.414035087719298, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '5564179', 'n_tokens_mistral': 359, 'n_tokens_neox': 354, 'n_words': 67}