Routing/ModuleFileLoader.php
public function load($file, $type = null)
    {
        $path = $this->locator->locate($file);

        $collection = new RouteCollection();
        if ($class = $this->findClass($path)) {
            // module file resource
            $collection->addResource(new FileResource($path));

            // module instance
            $module = $this->moduleManager->get($class);

            // routes prefixes
            $routeNamePrefix = $module->getRouteNamePrefix();
            $routePatternPrefix = $module->getRoutePatternPrefix();

            // route actions
            foreach ($module->getRouteActions() as $action) {
                // action file resource
                $reflection = new \ReflectionObject($action);
                $collection->addResource(new FileResource($reflection->getFileName()));

                // name (module prefix + action suffix)
                $name = $routeNamePrefix.$action->getRouteName();
                // pattern (module prefix + action suffix)
                if ('/' === $action->getRoutePattern() && '' !== $routePatternPrefix) {
                    $pattern = $routePatternPrefix;
                } else {
                    $pattern = $routePatternPrefix.$action->getRoutePattern();
                }
                // defaults (action defaults + defaults needed to execute)
                $defaults = array_merge($action->getRouteDefaults(), array(
                    '_controller' => 'PablodipModuleBundle:Module:execute',
                    '_module.module' => $class,
                    '_module.action' => $action->getName(),
                ));
                // requirements (just from the action)
                $requirements = $action->getRouteRequirements();
                // options (from the action)
                $options = $action->getRouteOptions();

                $collection->add($name, new Route($pattern, $defaults, $requirements, $options));
            }
        }

        return $collection;
    }
public function load($file, $type = null)
    {
        $path = $this->locator->locate($file);

        $collection = new RouteCollection();
        if ($class = $this->findClass($path)) {
            // module file resource
            $collection->addResource(new FileResource($path));

            // module instance
            $module = $this->moduleManager->get($class);

            // routes prefixes
            $routeNamePrefix = $module->getRouteNamePrefix();
            $routePatternPrefix = $module->getRoutePatternPrefix();

            // route actions
            foreach ($module->getRouteActions() as $action) {
                // action file resource
                $reflection = new \ReflectionObject($action);
                $collection->addResource(new FileResource($reflection->getFileName()));

                // name (module prefix + action suffix)
                $name = $routeNamePrefix.$action->getRouteName();
                // pattern (module prefix + action suffix)
                if ('/' === $action->getRoutePattern() && '' !== $routePatternPrefix) {
                    $pattern = $routePatternPrefix;
                } else {
                    $pattern = $routePatternPrefix.$action->getRoutePattern();
                }
                // defaults (action defaults + defaults needed to execute)
                $defaults = array_merge($action->getRouteDefaults(), array(
                    '_controller' => 'PablodipModuleBundle:Module:execute',
                    '_module.module' => $class,
                    '_module.action' => $action->getName(),
                ));
                // requirements (just from the action)
                $requirements = $action->getRouteRequirements();
                // options (from the action)
                $options = $action->getRouteOptions();

                $collection->add($name, new Route($pattern, $defaults, $requirements, $options));
            }
        }

        return $collection;
    }
public function load ( $ file , $ type = null ) { $ path = $ this -> locator -> locate ( $ file ) ; $ collection = new RouteCollection ( ) ; if ( $ class = $ this -> findClass ( $ path ) ) { // module file resource $ collection -> addResource ( new FileResource ( $ path ) ) ; // module instance $ module = $ this -> moduleManager -> get ( $ class ) ; // routes prefixes $ routeNamePrefix = $ module -> getRouteNamePrefix ( ) ; $ routePatternPrefix = $ module -> getRoutePatternPrefix ( ) ; // route actions foreach ( $ module -> getRouteActions ( ) as $ action ) { // action file resource $ reflection = new \ ReflectionObject ( $ action ) ; $ collection -> addResource ( new FileResource ( $ reflection -> getFileName ( ) ) ) ; // name (module prefix + action suffix) $ name = $ routeNamePrefix . $ action -> getRouteName ( ) ; // pattern (module prefix + action suffix) if ( '/' === $ action -> getRoutePattern ( ) && '' !== $ routePatternPrefix ) { $ pattern = $ routePatternPrefix ; } else { $ pattern = $ routePatternPrefix . $ action -> getRoutePattern ( ) ; } // defaults (action defaults + defaults needed to execute) $ defaults = array_merge ( $ action -> getRouteDefaults ( ) , array ( '_controller' => 'PablodipModuleBundle:Module:execute' , '_module.module' => $ class , '_module.action' => $ action -> getName ( ) , ) ) ; // requirements (just from the action) $ requirements = $ action -> getRouteRequirements ( ) ; // options (from the action) $ options = $ action -> getRouteOptions ( ) ; $ collection -> add ( $ name , new Route ( $ pattern , $ defaults , $ requirements , $ options ) ) ; } } return $ collection ; }
Loads from modules in a file

@param string $file A PHP file path
@param string $type The resource type

@return RouteCollection A RouteCollection instance
Loads from modules in a file