src/Provider/BuilderAliasProvider.php
protected function getBuilder($bundleName, $className)
    {
        $name = sprintf('%s:%s', $bundleName, $className);

        if (!isset($this->builders[$name])) {
            $class = null;
            $logs = [];
            $bundles = [];

            $allBundles = $this->kernel->getBundle($bundleName, false);

            // In Symfony 4, bundle inheritance is gone, so there is no way to get an array anymore.
            if (!is_array($allBundles)) {
                $allBundles = [$allBundles];
            }

            foreach ($allBundles as  $bundle) {
                $try = $bundle->getNamespace().'\\Menu\\'.$className;
                if (class_exists($try)) {
                    $class = $try;
                    break;
                }

                $logs[] = sprintf('Class "%s" does not exist for menu builder "%s".', $try, $name);
                $bundles[] = $bundle->getName();
            }

            if (null === $class) {
                if (1 === count($logs)) {
                    throw new \InvalidArgumentException($logs[0]);
                }

                throw new \InvalidArgumentException(sprintf('Unable to find menu builder "%s" in bundles %s.', $name, implode(', ', $bundles)));
            }

            $builder = new $class();
            if ($builder instanceof ContainerAwareInterface) {
                $builder->setContainer($this->container);
            }

            $this->builders[$name] = $builder;
        }

        return $this->builders[$name];
    }
protected function getBuilder($bundleName, $className)
    {
        $name = sprintf('%s:%s', $bundleName, $className);

        if (!isset($this->builders[$name])) {
            $class = null;
            $logs = [];
            $bundles = [];

            $allBundles = $this->kernel->getBundle($bundleName, false);

            // In Symfony 4, bundle inheritance is gone, so there is no way to get an array anymore.
            if (!is_array($allBundles)) {
                $allBundles = [$allBundles];
            }

            foreach ($allBundles as  $bundle) {
                $try = $bundle->getNamespace().'\\Menu\\'.$className;
                if (class_exists($try)) {
                    $class = $try;
                    break;
                }

                $logs[] = sprintf('Class "%s" does not exist for menu builder "%s".', $try, $name);
                $bundles[] = $bundle->getName();
            }

            if (null === $class) {
                if (1 === count($logs)) {
                    throw new \InvalidArgumentException($logs[0]);
                }

                throw new \InvalidArgumentException(sprintf('Unable to find menu builder "%s" in bundles %s.', $name, implode(', ', $bundles)));
            }

            $builder = new $class();
            if ($builder instanceof ContainerAwareInterface) {
                $builder->setContainer($this->container);
            }

            $this->builders[$name] = $builder;
        }

        return $this->builders[$name];
    }
protected function getBuilder ( $ bundleName , $ className ) { $ name = sprintf ( '%s:%s' , $ bundleName , $ className ) ; if ( ! isset ( $ this -> builders [ $ name ] ) ) { $ class = null ; $ logs = [ ] ; $ bundles = [ ] ; $ allBundles = $ this -> kernel -> getBundle ( $ bundleName , false ) ; // In Symfony 4, bundle inheritance is gone, so there is no way to get an array anymore. if ( ! is_array ( $ allBundles ) ) { $ allBundles = [ $ allBundles ] ; } foreach ( $ allBundles as $ bundle ) { $ try = $ bundle -> getNamespace ( ) . '\\Menu\\' . $ className ; if ( class_exists ( $ try ) ) { $ class = $ try ; break ; } $ logs [ ] = sprintf ( 'Class "%s" does not exist for menu builder "%s".' , $ try , $ name ) ; $ bundles [ ] = $ bundle -> getName ( ) ; } if ( null === $ class ) { if ( 1 === count ( $ logs ) ) { throw new \ InvalidArgumentException ( $ logs [ 0 ] ) ; } throw new \ InvalidArgumentException ( sprintf ( 'Unable to find menu builder "%s" in bundles %s.' , $ name , implode ( ', ' , $ bundles ) ) ) ; } $ builder = new $ class ( ) ; if ( $ builder instanceof ContainerAwareInterface ) { $ builder -> setContainer ( $ this -> container ) ; } $ this -> builders [ $ name ] = $ builder ; } return $ this -> builders [ $ name ] ; }
Creates and returns the builder that lives in the given bundle

The convention is to look in the Menu namespace of the bundle for
this class, to instantiate it with no arguments, and to inject the
container if the class is ContainerAware.

@param string $bundleName
@param string $className  The class name of the builder

@return object

@throws \InvalidArgumentException If the class does not exist
Creates and returns the builder that lives in the given bundle