<commit_before><?php

namespace Fervo\DeferredEventBundle\DependencyInjection\CompilerPass;

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

class ListenerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('fervo_deferred_event.dispatcher'))
        {
            return;
        }

        $fervoDispatcherDef = $container->getDefinition('fervo_deferred_event.dispatcher');
        $sfDispatcherDef = $container->getDefinition('event_dispatcher');

        $listenerTags = $container->findTaggedServiceIds('fervo_deferred_event.listener');
        foreach ($listenerTags as $id => $tags) {
            foreach ($tags as $tag) {
                $deferredEvents[] = $tag['event'];

                $callArgs = [
                    $tag['event'],
                    [new Reference($id), $tag['method']],
                ];

                if (isset($tag['priority'])) {
                    $callArgs[] = $tag['priority'];
                }

                $fervoDispatcherDef->addMethodCall('addListener', $callArgs);
            }
        }

        //if we don't got any deferredEvents..
        if (empty($deferredEvents)) {
            return;<commit_msg>Since the event_dispatcher now is an alias instead, its definition needs to be retrieved differently<commit_after><?php

namespace Fervo\DeferredEventBundle\DependencyInjection\CompilerPass;

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

class ListenerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('fervo_deferred_event.dispatcher'))
        {
            return;
        }

        $fervoDispatcherDef = $container->getDefinition('fervo_deferred_event.dispatcher');
        $sfDispatcherDef = $container->findDefinition('event_dispatcher');

        $listenerTags = $container->findTaggedServiceIds('fervo_deferred_event.listener');
        foreach ($listenerTags as $id => $tags) {
            foreach ($tags as $tag) {
                $deferredEvents[] = $tag['event'];

                $callArgs = [
                    $tag['event'],
                    [new Reference($id), $tag['method']],
                ];

                if (isset($tag['priority'])) {
                    $callArgs[] = $tag['priority'];
                }

                $fervoDispatcherDef->addMethodCall('addListener', $callArgs);
            }
        }

        //if we don't got any deferredEvents..
        if (empty($deferredEvents)) {
            return;
{'fraction_non_alphanumeric': 0.11455431754874652, 'fraction_numerical': 0.0, 'mean_word_length': 2.507936507936508, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3864034', 'n_tokens_mistral': 748, 'n_tokens_neox': 719, 'n_words': 127}