public static function locateResource($path, ContainerBuilder $container)
    {
        if (0 === stripos($path, '@')) {
            // Treat as a bundle path, e.g. @SomeBundle/path/to/something.

            // Correct backslashed paths.
            $path = str_replace('\\', '/', $path);

            $parts = explode('/', $path);
            $bundle = array_shift($parts);

            $bundleName = str_replace('@', '', $bundle);
            $bundleClass = null;
            foreach ($container->getParameter('kernel.bundles') as $name => $class) {
                if ($name === $bundleName) {
                    $bundleClass = $class;
                    break;
                }
            }

            if (null === $bundleClass) {
                throw new \RuntimeException(sprintf('Unable to find a bundle named "%s" for resource path "%s"', $bundleName, $path));
            }

            $refl = new \ReflectionClass($bundleClass);
            $bundleDir = dirname($refl->getFileName());
            return sprintf('%s/%s', $bundleDir, implode('/', $parts));
        }
        return $path;
    }
public static function locateResource($path, ContainerBuilder $container)
    {
        if (0 === stripos($path, '@')) {
            // Treat as a bundle path, e.g. @SomeBundle/path/to/something.

            // Correct backslashed paths.
            $path = str_replace('\\', '/', $path);

            $parts = explode('/', $path);
            $bundle = array_shift($parts);

            $bundleName = str_replace('@', '', $bundle);
            $bundleClass = null;
            foreach ($container->getParameter('kernel.bundles') as $name => $class) {
                if ($name === $bundleName) {
                    $bundleClass = $class;
                    break;
                }
            }

            if (null === $bundleClass) {
                throw new \RuntimeException(sprintf('Unable to find a bundle named "%s" for resource path "%s"', $bundleName, $path));
            }

            $refl = new \ReflectionClass($bundleClass);
            $bundleDir = dirname($refl->getFileName());
            return sprintf('%s/%s', $bundleDir, implode('/', $parts));
        }
        return $path;
    }
public static function locateResource ( $ path , ContainerBuilder $ container ) { if ( 0 === stripos ( $ path , '@' ) ) { // Treat as a bundle path, e.g. @SomeBundle/path/to/something. // Correct backslashed paths. $ path = str_replace ( '\\' , '/' , $ path ) ; $ parts = explode ( '/' , $ path ) ; $ bundle = array_shift ( $ parts ) ; $ bundleName = str_replace ( '@' , '' , $ bundle ) ; $ bundleClass = null ; foreach ( $ container -> getParameter ( 'kernel.bundles' ) as $ name => $ class ) { if ( $ name === $ bundleName ) { $ bundleClass = $ class ; break ; } } if ( null === $ bundleClass ) { throw new \ RuntimeException ( sprintf ( 'Unable to find a bundle named "%s" for resource path "%s"' , $ bundleName , $ path ) ) ; } $ refl = new \ ReflectionClass ( $ bundleClass ) ; $ bundleDir = dirname ( $ refl -> getFileName ( ) ) ; return sprintf ( '%s/%s' , $ bundleDir , implode ( '/' , $ parts ) ) ; } return $ path ; }
Locates a file resource path for a given config path.
Is needed in order to retrieve a bundle's directory, if used.


@static
@param   string              $path
@param   ContainerBuilder    $container
@return  string
@throws  \RuntimeException
Locates a file resource path for a given config path . Is needed in order to retrieve a bundle s directory if used .