Newscoop\NewscoopBundle\Routing\PluginsLoader::load PHP Method

load() public method

public load ( $resource, $type = null )
    public function load($resource, $type = null)
    {
        if (true === $this->loaded) {
            throw new \RuntimeException('Do not add this loader twice');
        }
        $routes = new \Symfony\Component\Routing\RouteCollection();
        $availablePlugins = $this->pluginsManager->getInstalledPlugins();
        $dirs = array();
        foreach ($availablePlugins as $plugin) {
            $pluginPath = explode('\\', $plugin);
            $directoryPath = realpath(__DIR__ . '/../../../../plugins/' . $pluginPath[0] . '/' . $pluginPath[1] . '/Resources/config/routing.yml');
            if ($directoryPath) {
                $dirs[] = realpath(__DIR__ . '/../../../../plugins/' . $pluginPath[0] . '/' . $pluginPath[1] . '/Resources/config/');
            }
        }
        $routesCollection = new \Symfony\Component\Routing\RouteCollection();
        foreach ($dirs as $directory) {
            $importedRoutes = $this->import($directory . '/routing.yml', 'yaml');
            $routesCollection->addCollection($importedRoutes);
        }
        return $routesCollection;
    }