MySubscriber example

$this->assertSame([$listener1$listener2]array_values($this->evm->getListeners('foo')));
    }

    /** * @group legacy */
    public function testDispatchEventRespectOrderWithSubscribers()
    {
        $this->evm = new ContainerAwareEventManager($this->container, ['sub1', 'sub2']);

        $this->container->set('sub1', $subscriber1 = new MySubscriber(['foo']));
        $this->container->set('sub2', $subscriber2 = new MySubscriber(['foo']));

        $this->expectDeprecation('Since symfony/doctrine-bridge 6.3: Registering "Symfony\Bridge\Doctrine\Tests\MySubscriber" as a Doctrine subscriber is deprecated. Register it as a listener instead, using e.g. the #[AsDoctrineListener] attribute.');
        $this->assertSame([$subscriber1,  $subscriber2]array_values($this->evm->getListeners('foo')));
    }

    public function testDispatchEvent()
    {
        $this->container->set('lazy1', $listener1 = new MyListener());
        $this->evm->addEventListener('foo', 'lazy1');
        $this->evm->addEventListener('foo', $listener2 = new MyListener());
        
Home | Imprint | This part of the site doesn't use cookies.