<commit_before><?php
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\AdminBundle\Twig\Extension;

use Darvin\Utils\Strings\StringsUtil;

/**
 * Globals Twig extension
 */
class GlobalsExtension extends \Twig_Extension
{
    /**
     * @var array
     */
    private $locales;

    /**
     * @var string
     */
    private $projectTitle;

    /**
     * @var string
     */
    private $projectUrl;

    /**
     * @var string
     */
    private $visualAssetsPath;

    /**
     * @var string
     */
    private $yandexTranslateApiKey;

    /**
     * @var array
     */
    private $globals;

    /**
     * @var bool
     */
    private $initialized;

    /**
     * @param array  $locales               Available locales
     * @param string $projectTitle          Project title
     * @param string $projectUrl            Project URL
     * @param string $visualAssetsPath      Visual assets path
     * @param string $yandexTranslateApiKey Yandex.Translate API key
     */
    public function __construct(array $locales, $projectTitle, $projectUrl, $visualAssetsPath, $yandexTranslateApiKey)
    {
        $this->locales = $locales;
        $this->projectTitle = $projectTitle;
        $this->projectUrl = $projectUrl;
        $this->visualAssetsPath = $visualAssetsPath;
        $this->yandexTranslateApiKey = $yandexTranslateApiKey;
        $this->globals = array();
        $this->initialized = false;
    }

    /**
     * {@inheritdoc}
     */
    public function getGlobals()
    {
        $this->init();

        return $this->globals;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'darvin_admin_globals_extension';
    }

    private function init()
    {
        if ($this->initialized) {
            return;
        }
        foreach (get_object_vars($this) as $name => $value) {
            $this->globals['darvin_admin_'.StringsUtil::toUnderscore($name)] = $value;
        }

        $this->initialized = true;
    }
}
<commit_msg>Fix Twig extensions with "getGlobals()" method.<commit_after><?php
/**
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\AdminBundle\Twig\Extension;

use Darvin\Utils\Strings\StringsUtil;

/**
 * Globals Twig extension
 */
class GlobalsExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
    /**
     * @var array
     */
    private $locales;

    /**
     * @var string
     */
    private $projectTitle;

    /**
     * @var string
     */
    private $projectUrl;

    /**
     * @var string
     */
    private $visualAssetsPath;

    /**
     * @var string
     */
    private $yandexTranslateApiKey;

    /**
     * @var array
     */
    private $globals;

    /**
     * @var bool
     */
    private $initialized;

    /**
     * @param array  $locales               Available locales
     * @param string $projectTitle          Project title
     * @param string $projectUrl            Project URL
     * @param string $visualAssetsPath      Visual assets path
     * @param string $yandexTranslateApiKey Yandex.Translate API key
     */
    public function __construct(array $locales, $projectTitle, $projectUrl, $visualAssetsPath, $yandexTranslateApiKey)
    {
        $this->locales = $locales;
        $this->projectTitle = $projectTitle;
        $this->projectUrl = $projectUrl;
        $this->visualAssetsPath = $visualAssetsPath;
        $this->yandexTranslateApiKey = $yandexTranslateApiKey;
        $this->globals = array();
        $this->initialized = false;
    }

    /**
     * {@inheritdoc}
     */
    public function getGlobals()
    {
        $this->init();

        return $this->globals;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'darvin_admin_globals_extension';
    }

    private function init()
    {
        if ($this->initialized) {
            return;
        }
        foreach (get_object_vars($this) as $name => $value) {
            $this->globals['darvin_admin_'.StringsUtil::toUnderscore($name)] = $value;
        }

        $this->initialized = true;
    }
}

{'fraction_non_alphanumeric': 0.12252093433230499, 'fraction_numerical': 0.0017628911414720142, 'mean_word_length': 2.1346685082872927, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5812699', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1360, 'n_words': 301}