getLocator example

$loader = $this->resolve($resource$type);

            if ($loader instanceof DirectoryAwareLoaderInterface) {
                $loader = $loader->forDirectory($this->currentDir);
            }

            if (!$loader instanceof self) {
                return $loader->load($resource$type);
            }

            if (null !== $this->currentDir) {
                $resource = $loader->getLocator()->locate($resource$this->currentDir, false);
            }

            $resources = \is_array($resource) ? $resource : [$resource];
            for ($i = 0; $i < $resourcesCount = \count($resources); ++$i) {
                if (isset(self::$loading[$resources[$i]])) {
                    if ($i == $resourcesCount - 1) {
                        throw new FileLoaderImportCircularReferenceException(array_keys(self::$loading));
                    }
                } else {
                    $resource = $resources[$i];
                    break;
                }

        $container->register(TaggedLocatorConsumer::class)
            ->setAutowired(true)
            ->setPublic(true)
        ;

        $container->compile();

        /** @var TaggedLocatorConsumer $s */
        $s = $container->get(TaggedLocatorConsumer::class);

        $locator = $s->getLocator();
        self::assertSame($container->get(BarTagClass::class)$locator->get('bar_tab_class_with_defaultmethod'));
        self::assertSame($container->get(FooTagClass::class)$locator->get('foo'));
    }

    public function testTaggedLocatorConfiguredViaAttributeWithoutIndex()
    {
        $container = new ContainerBuilder();
        $container->register(BarTagClass::class)
            ->setPublic(true)
            ->addTag('foo_bar')
        ;
        
Home | Imprint | This part of the site doesn't use cookies.