<commit_before><?php

declare(strict_types=1);

namespace Brick\App\Plugin;

use Brick\App\Event\ControllerInvocatedEvent;
use Brick\App\Event\RouteMatchedEvent;
use Brick\App\Controller\Annotation\Transactional;
use Brick\Event\EventDispatcher;
use Brick\App\RouteMatch;

use Doctrine\DBAL\Connection;
use Doctrine\Common\Annotations\Reader;

/**
 * Configures the start of a database transaction with annotations.
 */
class TransactionalPlugin extends AbstractAnnotationPlugin
{
    /**
     * @var Connection
     */
    private Connection $connection;

    /**
     * Class constructor.
     *
     * @param Connection $connection
     * @param Reader     $annotationReader
     */
    public function __construct(Connection $connection, Reader $annotationReader)
    {
        parent::__construct($annotationReader);

        $this->connection = $connection;
    }

    /**
     * {@inheritdoc}
     */
    public function register(EventDispatcher $dispatcher) : void
    {
        $dispatcher->addListener(RouteMatchedEvent::class, function (RouteMatchedEvent $event) {
            $annotation = $this->getTransactionalAnnotation($event->getRouteMatch());

            if ($annotation) {
                $this->connection->setTransactionIsolation($annotation->getIsolationLevel());<commit_msg>Deprecate TransactionalPlugin<commit_after><?php

declare(strict_types=1);

namespace Brick\App\Plugin;

use Brick\App\Event\ControllerInvocatedEvent;
use Brick\App\Event\RouteMatchedEvent;
use Brick\App\Controller\Annotation\Transactional;
use Brick\Event\EventDispatcher;
use Brick\App\RouteMatch;

use Doctrine\DBAL\Connection;
use Doctrine\Common\Annotations\Reader;

/**
 * Configures the start of a database transaction with annotations.
 *
 * @deprecated
 */
class TransactionalPlugin extends AbstractAnnotationPlugin
{
    /**
     * @var Connection
     */
    private Connection $connection;

    /**
     * Class constructor.
     *
     * @param Connection $connection
     * @param Reader     $annotationReader
     */
    public function __construct(Connection $connection, Reader $annotationReader)
    {
        parent::__construct($annotationReader);

        $this->connection = $connection;
    }

    /**
     * {@inheritdoc}
     */
    public function register(EventDispatcher $dispatcher) : void
    {
        $dispatcher->addListener(RouteMatchedEvent::class, function (RouteMatchedEvent $event) {
            $annotation = $this->getTransactionalAnnotation($event->getRouteMatch());

            if ($annotation) {
                $this->connection->setTransactionIsolation($annotation->getIsolationLevel());
{'fraction_non_alphanumeric': 0.10980243161094225, 'fraction_numerical': 0.0007598784194528875, 'mean_word_length': 3.500854700854701, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6182323', 'n_tokens_mistral': 714, 'n_tokens_neox': 692, 'n_words': 137}