<commit_before><?php

/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Twig;

use Sylius\Bundle\CoreBundle\Application\Kernel;

/**
 * @author <NAME> <<EMAIL>>
 */
final class NotificationWidgetExtension extends \Twig_Extension
{
    /**
     * @var bool
     */
    private $areNotificationsEnabled;

    /**
     * @var int
     */
    private $checkFrequency;

    /**
     * @param bool $areNotificationsEnabled
     * @param int $checkFrequency
     */
    public function __construct($areNotificationsEnabled, $checkFrequency)
    {
        $this->areNotificationsEnabled = $areNotificationsEnabled;
        $this->checkFrequency = $checkFrequency;
    }

    /**
     * @return array
     */
    public function getFunctions()
    {
        return [
            new \Twig_SimpleFunction(
                'sylius_render_notifications_widget',
                [$this, 'renderWidget'],
                [
                    'needs_environment' => true,
                    'is_safe' => ['html'],
                ]
            ),
        ];
    }

    /**
     * @param \Twig_Environment $environment
     *
     * @return string
     */
    public function renderWidget(\Twig_Environment $environment)
    {
        if (!$this->areNotificationsEnabled) {
            return '';
        }

        return $environment->render('@SyliusAdmin/_notification.html.twig', [
            'frequency' => $this->checkFrequency,
            'currentVersion' => Kernel::VERSION,
        ]);
    }
}
<commit_msg>Use non-deprecated classes for registering addons<commit_after><?php

/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Twig;

use Sylius\Bundle\CoreBundle\Application\Kernel;

/**
 * @author <NAME> <<EMAIL>>
 */
final class NotificationWidgetExtension extends \Twig_Extension
{
    /**
     * @var bool
     */
    private $areNotificationsEnabled;

    /**
     * @var int
     */
    private $checkFrequency;

    /**
     * @param bool $areNotificationsEnabled
     * @param int $checkFrequency
     */
    public function __construct($areNotificationsEnabled, $checkFrequency)
    {
        $this->areNotificationsEnabled = $areNotificationsEnabled;
        $this->checkFrequency = $checkFrequency;
    }

    /**
     * @return array
     */
    public function getFunctions()
    {
        return [
            new \Twig_Function(
                'sylius_render_notifications_widget',
                [$this, 'renderWidget'],
                [
                    'needs_environment' => true,
                    'is_safe' => ['html'],
                ]
            ),
        ];
    }

    /**
     * @param \Twig_Environment $environment
     *
     * @return string
     */
    public function renderWidget(\Twig_Environment $environment)
    {
        if (!$this->areNotificationsEnabled) {
            return '';
        }

        return $environment->render('@SyliusAdmin/_notification.html.twig', [
            'frequency' => $this->checkFrequency,
            'currentVersion' => Kernel::VERSION,
        ]);
    }
}

{'fraction_non_alphanumeric': 0.11711972238288028, 'fraction_numerical': 0.000578368999421631, 'mean_word_length': 2.0583554376657824, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, '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': '5307336', 'n_tokens_mistral': 979, 'n_tokens_neox': 940, 'n_words': 201}