<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\UiBundle\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;

/**
 * @internal
 * @experimental
 */
final class TemplateBlockDataCollector extends DataCollector
{
    /** @var TemplateBlockRenderingHistory */
    private $templateBlockRenderingHistory;

    public function __construct(TemplateBlockRenderingHistory $templateBlockRenderingHistory)
    {
        $this->templateBlockRenderingHistory = $templateBlockRenderingHistory;
        $this->reset();
    }

    public function collect(Request $request, Response $response): void
    {
        $this->data['renderedEvents'] = $this->templateBlockRenderingHistory->getRenderedEvents();
    }

    public function getRenderedEvents(): array
    {
        return $this->data['renderedEvents'];<commit_msg>Fixed compatibility with newer version of data collectors<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\UiBundle\DataCollector;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;

/**
 * @internal
 * @experimental
 */
final class TemplateBlockDataCollector extends DataCollector
{
    /** @var TemplateBlockRenderingHistory */
    private $templateBlockRenderingHistory;

    public function __construct(TemplateBlockRenderingHistory $templateBlockRenderingHistory)
    {
        $this->templateBlockRenderingHistory = $templateBlockRenderingHistory;
        $this->reset();
    }

    public function collect(Request $request, Response $response, \Throwable $exception = null): void
    {
        $this->data['renderedEvents'] = $this->templateBlockRenderingHistory->getRenderedEvents();
    }

    public function getRenderedEvents(): array
    {
        return $this->data['renderedEvents'];
{'fraction_non_alphanumeric': 0.09789029535864979, 'fraction_numerical': 0.0008438818565400844, 'mean_word_length': 4.475750577367205, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '3303260', 'n_tokens_mistral': 619, 'n_tokens_neox': 619, 'n_words': 153}