Path routing

@param AbstractResourceBundle $bundle

@return null
545611
private function patchRouting(AbstractResourceBundle $bundle)
    {
        $routingPath = $bundle->getPath() . '/Resources/config/routing/';
        $prefix = $this->getBundlePrefix();
        $namePrefix = strtolower($this->getBundlePrefix($bundle) . '_' . $this->model);
        $bundleName = $bundle->getName();
        $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($this->bundle->getName()) . '\\' . $this->model;

        $identifier = $this->getContainer()->get('doctrine')
            ->getManager()
            ->getClassMetadata($entityClass)
            ->getIdentifier();

        $this->renderFile('controller/routing/routing.yml.twig',
            $routingPath . strtolower($this->model) . '.yml',
            array(
                'route_name_prefix' => $namePrefix,
                'bundle' => $prefix,
                'entity' => $this->model,
                'identifier' => $identifier[0],
                'resource' => $bundle->getName(),
                'actions' => $this->configuration['actions']
            )
        );

        $path = $routingPath . 'main.yml';
        if (!file_exists($path)) {
            $path = $this->getContainer()->get('kernel')->getRootDir() . '/config/routing.yml';
        }

        $prefixName = strtolower($this->model);
        $nodeDeclaration = <<<EOF
$namePrefix:
    resource: @$bundleName/Resources/config/routing/$prefixName.yml
    prefix: /$prefixName
EOF;

        if (!$this->refExist($path, $namePrefix)) {
            $this->dumpFile($path, "\n" . $nodeDeclaration, false, false);
        }

        return null;
    }
493837
public function load($resource, $type = null): RouteCollection
    {
        $resource = (string)$resource;
        if (in_array($resource, $this->descriptions)) {
            throw new \RuntimeException("Resource '$resource' was already loaded");
        }

        $description = $this->repository->get($resource);

        $routes           = new RouteCollection();
        $router           = $description->getExtension('router') ?: "$this->typeName.controller";
        $routerController = $description->getExtension('router-controller');

        foreach ($description->getPaths() as $pathItem) {
            $relativePath = ltrim($pathItem->getPath(), '/');
            $resourceName = strpos($relativePath, '/')
                ? substr($relativePath, 0, strpos($relativePath, '/'))
                : $relativePath;

            $routerController = $pathItem->getExtension('router-controller') ?: $routerController;

            foreach ($pathItem->getOperations() as $operation) {
                $controllerKey = $this->resolveControllerKey(
                    $operation,
                    $resourceName,
                    $router,
                    $routerController
                );
                $defaults      = [
                    '_controller'               => $controllerKey,
                    RequestMeta::ATTRIBUTE_URI  => $resource,
                    RequestMeta::ATTRIBUTE_PATH => $pathItem->getPath(),
                ];

                $route = new Route(
                    $pathItem->getPath(),
                    $defaults,
                    $this->resolveRequirements($operation),
                    [],
                    '',
                    $description->getSchemes()
                );
                $route->setMethods($operation->getMethod());
                $routes->add($this->createRouteId($resource, $pathItem->getPath(), $controllerKey), $route);
            }
        }

        $this->descriptions[] = $resource;

        return $routes;
    }
1283387
protected function getBundleName($path)
    {
        if (is_dir($path)) {
            $finder = new Finder();
            $bundles = $finder->files()->depth(0)->name('*Bundle.php')->in($path);
            foreach ($bundles as $bundle) {
                return basename($bundle->getFilename(), 'Bundle.php');
            }
        }

        return null;
    }
651141
public static function getRootDir($bundlepath = false)
    {
        $dir = dirname(static::getCont()->getParameter('kernel.root_dir'));

        if ($bundlepath) {
            $n = get_called_class();
            $n = substr($n, 0, -strlen(strrchr($n, '\\')));
            $n = substr($n, 0, -strlen(strrchr($n, '\\')));
            $n = str_replace('\\', '/', $n);
            $dir .= "/src/$n";
        }

        return $dir;
    }
941145
private function getBundleValue(ResourceBundleInterface $bundle, string $key): array
    {
        return [
            BundleStorageInterface::INDEX_PAIR_VALUE  => $bundle->getValue($key),
            BundleStorageInterface::INDEX_PAIR_LOCALE => $bundle->getLocale(),
        ];
    }
1074428
public static function routes($bundle)
		{
			if (static::routed($bundle)) {
				return;
			}

			$path = static::path($bundle) . 'routes.php';

			// By setting the bundle property on the router, the router knows what
			// value to replace the (:bundle) place-holder with when the bundle
			// routes are added, keeping the routes flexible.
			Router::$bundle = static::option($bundle, 'handles');

			if (!static::routed($bundle) && File::exists($path)) {
				static::$routed[] = $bundle;
				require $path;
			}
		}
40179
private function load(SplFileInfo $file, Bundle $bundle = null)
    {
        $id = null;

        if (null === $bundle) {
            if (false !== $appResourcesViewsPath = realpath($this->kernel->getRootDir() . '/Resources/views')) {
                if (0 === mb_strpos($file->getRealPath(), $appResourcesViewsPath)) {
                    $id = mb_strcut($file->getRealPath(), 1 + mb_strlen($appResourcesViewsPath));
                }
            }
        } else {
            if (false !== $bundleResourcesViewsPath = realpath($bundle->getPath() . '/Resources/views')) {
                if (0 === mb_strpos($file->getRealPath(), $bundleResourcesViewsPath)) {
                    $id = '@' . mb_strcut($bundle->getName(), 0, -6);
                    $id .= mb_strcut($file->getRealPath(), mb_strlen($bundleResourcesViewsPath));
                }
            }
        }

        if (null !== $id) {
            $this->files[$id] = [
                'id' => $id,
                'resolved' => false,
                'path' => $file->getRealPath(),
                'file' => $file->getBasename(),
                'bundle_name' => $bundle ? $bundle->getName() : null,
                'extends' => [],
                'uses' => [],
                'includes' => [],
                'defined_blocks' => [],
                'called_blocks' => [],
            ];
        }
    }
1070110
protected function getAvailablePages(BundleInterface $bundle)
    {
        $pages = [];
        $counter = 1;

        // Get the available pages from disc
        $dir = $bundle->getPath().'/Entity/Pages/';
        if (file_exists($dir) && is_dir($dir)) {
            $finder = new Finder();
            $finder->files()->in($dir)->depth('== 0');
            foreach ($finder as $file) {
                $pages[$counter++] = [
                    'name' => substr($file->getFileName(), 0, strlen($file->getFileName()) - 4),
                    'path' => $file->getPathName(),
                ];
            }
        }

        return $pages;
    }
1193829
protected function getSchemasFromBundle(BundleInterface $bundle)
    {
        $finalSchemas = array();

        if (is_dir($dir = $bundle->getPath() . '/Resources/config')) {
            $finder = new Finder();
            $schemas = $finder->files()->name('*schema.xml')->followLinks()->in($dir);

            if (iterator_count($schemas)) {
                foreach ($schemas as $schema) {
                    $logicalName = $this->transformToLogicalName($schema, $bundle);
                    $finalSchema = new \SplFileInfo($this->getFileLocator()->locate($logicalName));

                    $finalSchemas[(string)$finalSchema] = array($bundle, $finalSchema);
                }
            }
        }

        return $finalSchemas;
    }
737187
public static function load(BundleInterface $bundle)
    {
        if (is_dir($bundle->getPath())) {
            self::$bundlesLoaded[$bundle->getName()] = [
                'namespace' => $bundle->getNamespace(),
                'path' => $bundle->getPath()
            ];

            if (!self::$classLoader) {
                self::$classLoader = new ClassLoader();
            }

            self::$classLoader->addPsr4($bundle->getNamespace(), $bundle->getPath());
            self::$classLoader->register();
        } else {
            throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundle->getName()));
        }
    }
369859
private function getPath($view)
    {
        $tmp = explode(':', $view);
        $bundlePath = $this->kernel->getBundle($tmp[0])->getPath();

        return $bundlePath . '/Resources/views/' . $tmp[1] . '/' . $tmp[2];
    }
1121829
private void recurse(Bundle bundle, String path, IResourceVisitor visitor, String relPathName) throws IOException {
		Enumeration<?> entries = bundle.findEntries(path, "*", false); //$NON-NLS-1$
		if (entries != null) {
			while (entries.hasMoreElements()) {
				URL child = (URL)entries.nextElement();
				String childPath = child.getPath();
				String temp = childPath;
				if (temp.endsWith("/")) { //$NON-NLS-1$
					temp = temp.substring(0, temp.length()-1);
				}
				int idx = temp.lastIndexOf("/"); //$NON-NLS-1$
				String childName = temp.substring(idx+1);
				String relPath = relPathName
						+ (relPathName.length() == 0 ? "" : "/") //$NON-NLS-1$ //$NON-NLS-2$
						+ childName;
				boolean result = visitor.visitResource(
						new VisitorResource(child, relPath), relPath);
				if (result && child.getPath().endsWith("/")) { //$NON-NLS-1$
					recurse(bundle, childPath, visitor, relPath);
				}
			}
		}
	}
502007
protected function getSkeletonDirs(BundleInterface $bundle = null)
    {
        $skeletonDirs = array();

        if (isset($bundle) && is_dir($dir = $bundle->getPath().'/Resources/SymfonyIdAdminBundle/skeleton')) {
            $skeletonDirs[] = $dir;
        }

        /** @var KernelInterface $kernel */
        $kernel = $this->getContainer()->get('kernel');
        if (is_dir($dir = $kernel->getRootDir().'/Resources/SymfonyIdAdminBundle/skeleton')) {
            $skeletonDirs[] = $dir;
        }

        $reflClass = new \ReflectionObject($this);
        $skeletonDirs[] = dirname($reflClass->getFileName()).'/../Resources/skeleton';
        $skeletonDirs[] = dirname($reflClass->getFileName()).'/../Resources';

        return $skeletonDirs;
    }
1150327
public static function loadAll(array $bundles)
    {
        foreach ($bundles as $bundle) {
            if (!$bundle instanceof BundleInterface) {
                throw new InvalidArgumentException('Bundle must be instance of "Rad\Core\BundleInterface".');
            }

            self::load($bundle);
        }
    }
873598
public static function loadBundle(&$bundle)
    {
        if (sizeof($bundle->content) == 0) {
            return;
        }
        
        // check for cached, preloaded bundle
        $bundleCache = Cache::getInstance('MEMCACHE', 'APC', 'FILE_ENCODED');
        $bundleCachePath = "xqbundle/{$bundle->bundleId}";
        
        if (!DEBUG && ($bundleCache->available() && $bundleCache->hasCached($bundleCachePath))) {
            $bundle = $bundleCache->getCached($bundleCachePath);
            return;
        }
        
        // preload
        $bundle->lastModified = null;
        $bundle->files = array();
        
        $fileNames = array();
        foreach ($bundle->content as $file) {
            $preloaded = self::getBundleFileDetails($bundle, $file);
            
            $bundle->files[] = $preloaded;
            $fileNames[] = $preloaded->path;
        }
        
        $bundle->contentType = self::getBundleContentType($bundle);
        $bundle->tag = md5($bundle->lastModified . $bundle->bundleId . implode('-', $fileNames));
        
        $bundle->output = self::getBundleContent($bundle);
        
        if (!DEBUG && $bundleCache->available()) {
            $bundleCache->cache($bundleCachePath, $bundle);
        }
    }
249809
@Override
	public JoinableResourceBundle resolveBundleForPath(String path) {

		JoinableResourceBundle theBundle = null;
		for (Iterator<JoinableResourceBundle> it = bundles.iterator(); it.hasNext();) {
			JoinableResourceBundle bundle = it.next();
			if (bundle.getId().equals(path) || bundle.belongsToBundle(path)) {
				theBundle = bundle;
				break;
			}
		}
		return theBundle;
	}
180122
public synchronized void initPathToResourceBundleMap(List<JoinableResourceBundle> bundles) throws IOException {

		for (JoinableResourceBundle bundle : bundles) {

			// Remove bundle reference from existing mapping if exists
			removePathMappingFromPathMap(bundle);

			List<PathMapping> mappings = bundle.getMappings();
			for (PathMapping pathMapping : mappings) {
				register(pathMapping);
			}

			// Register file path mapping for linked resources
			List<FilePathMapping> fMappings = bundle.getLinkedFilePathMappings();
			for (FilePathMapping fMapping : fMappings) {
				register(fMapping);
			}
		}
	}