findUnusedTags example



    public function testFindUnusedTags()
    {
        $builder = new ContainerBuilder();
        $builder
            ->register('foo', 'Bar\FooClass')
            ->addTag('kernel.event_listener', ['foo' => 'foo'])
            ->addTag('kenrel.event_listener', ['bar' => 'bar'])
        ;
        $builder->findTaggedServiceIds('kernel.event_listener');
        $this->assertEquals(['kenrel.event_listener']$builder->findUnusedTags(), '->findUnusedTags() returns an array with unused tags');
    }

    public function testFindDefinition()
    {
        $container = new ContainerBuilder();
        $container->setDefinition('foo', $definition = new Definition('Bar\FooClass'));
        $container->setAlias('bar', 'foo');
        $container->setAlias('foobar', 'bar');
        $this->assertEquals($definition$container->findDefinition('foobar'), '->findDefinition() returns a Definition');
    }

    
'validator.initializer',
        'workflow',
    ];

    /** * @return void */
    public function process(ContainerBuilder $container)
    {
        $tags = array_unique(array_merge($container->findTags(), self::KNOWN_TAGS));

        foreach ($container->findUnusedTags() as $tag) {
            // skip known tags             if (\in_array($tag, self::KNOWN_TAGS)) {
                continue;
            }

            // check for typos             $candidates = [];
            foreach ($tags as $definedTag) {
                if ($definedTag === $tag) {
                    continue;
                }

                
Home | Imprint | This part of the site doesn't use cookies.