<commit_before><?php

namespace Symfony\Bundle\DoctrineBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
{
    protected $container;

    public function process(ContainerBuilder $container)
    {
        $this->container = $container;
        foreach ($container->getDefinitions() as $id => $definition) {
            if ('%doctrine.dbal.event_manager.class%' !== $definition->getClass()) {
                continue;
            }

            $prefix = substr($id, 0, -1 * strlen('_connection.event_manager'));
            $this->registerListeners($prefix, $definition);
            $this->registerSubscribers($prefix, $definition);
        }
    }

    protected function registerSubscribers($prefix, $definition)
    {
        $subscribers = array_merge(
            $this->container->findTaggedServiceIds('doctrine.common.event_subscriber'),
            $this->container->findTaggedServiceIds($prefix.'_event_subscriber')
        );

        foreach ($subscribers as $id => $instances) {
            $definition->addMethodCall('addEventSubscriber', array(new Reference($id)));
        }
    }

    protected function registerListeners($prefix, $definition)
    {<commit_msg>[DoctrineBundle] fixed regression<commit_after><?php

namespace Symfony\Bundle\DoctrineBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
{
    protected $container;

    public function process(ContainerBuilder $container)
    {
        $this->container = $container;
        foreach ($container->getDefinitions() as $id => $definition) {
            if (!$definition instanceof DefinitionDecorator || 'doctrine.dbal.connection.event_manager' !== $definition->getParent()) {
                continue;
            }

            $prefix = substr($id, 0, -strlen('_connection.event_manager'));
            $this->registerListeners($prefix, $definition);
            $this->registerSubscribers($prefix, $definition);
        }
    }

    protected function registerSubscribers($prefix, $definition)
    {
        $subscribers = array_merge(
            $this->container->findTaggedServiceIds('doctrine.common.event_subscriber'),
            $this->container->findTaggedServiceIds($prefix.'_event_subscriber')
        );

        foreach ($subscribers as $id => $instances) {
            $definition->addMethodCall('addEventSubscriber', array(new Reference($id)));
        }
    }

    protected function registerListeners($prefix, $definition)
    {
{'fraction_non_alphanumeric': 0.11366666666666667, 'fraction_numerical': 0.001, 'mean_word_length': 3.58868501529052, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '260387', 'n_tokens_mistral': 763, 'n_tokens_neox': 755, 'n_words': 124}