TaggedLocator example

    {
    }
}

#[AsDecorator(decorates: AsDecoratorFoo::class)] class AutowireNestedAttributes implements AsDecoratorInterface
{
    public function __construct(
        #[Autowire([             'decorated' => new AutowireDecorated(),
            'iterator' => new TaggedIterator('foo'),
            'locator' => new TaggedLocator('foo'),
            'service' => new Autowire(service: 'bar')
        ])] array $options)
    {
    }
}
if (!property_exists(SubscribedService::class, 'attributes')) {
            $this->markTestSkipped('Requires symfony/service-contracts 3.2+');
        }

        $container = new ContainerBuilder();

        $subscriber = new class() implements ServiceSubscriberInterface {
            public static function getSubscribedServices(): array
            {
                return [
                    new SubscribedService('tagged.iterator', 'iterable', attributes: new TaggedIterator('tag')),
                    new SubscribedService('tagged.locator', PsrContainerInterface::class, attributes: new TaggedLocator('tag')),
                    new SubscribedService('autowired', 'stdClass', attributes: new Autowire(service: 'service.id')),
                    new SubscribedService('autowired.nullable', 'stdClass', nullable: true, attributes: new Autowire(service: 'service.id')),
                    new SubscribedService('autowired.parameter', 'string', attributes: new Autowire('%parameter.1%')),
                    new SubscribedService('autowire.decorated', \stdClass::class, attributes: new AutowireDecorated()),
                    new SubscribedService('target', \stdClass::class, attributes: new Target('someTarget')),
                ];
            }
        };

        $container->setParameter('parameter.1', 'foobar');
        $container->register('foo', $subscriber::class)
            
Home | Imprint | This part of the site doesn't use cookies.