protected function parseRoutesFromFile($filename)
    {
        // Assume empty result
        $routes            = [];
        $actionsWithRoutes = [];

        // Check if file exists ...
        if (true === $this->getRegistry()->getFilesystem()->readable($filename)) {
            include $filename;

            $content = file_get_contents($filename);
            $matches = preg_match('/class\s([A-Za-z\_]+)/', $content, $classes);

            // Process all found classes ...
            if ($matches > 0) {

                // Use our selection from result
                $className = $classes[1];

                // Lookup for namespace ...
                $namespaceCount = preg_match('#^namespace\s+(.+?);$#sm', $content, $namespace);

                // Extract namespace of file/class if found ...
                if ($namespaceCount > 0) {
                    $namespace = $namespace[1].'\\';
                } else {
                    $namespace = '';
                }

                // Combine everything to a full qualified className ...
                $fullQualifiedClassName = $namespace.$className;

                $reflection = new ReflectionClass($fullQualifiedClassName);

                // Extract the methods (potentially an ...Action())
                $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);

                foreach ($methods as $key => $reflection) {
                    if (preg_match('/(Action)$/ui', $reflection->name)) {
                        if (isset($actionsWithRoutes[$filename]) === false) {
                            $actionsWithRoutes[$filename] = [];
                        }

                        $actionsWithRoutes[$filename][$reflection->name] =
                            $this->getAnnotationReader()->getMethodAnnotations($reflection);
                    }
                }
            }

            $routes = $this->sortRoutes($actionsWithRoutes);
        }

        return $routes;
    }
protected function parseRoutesFromFile($filename)
    {
        // Assume empty result
        $routes            = [];
        $actionsWithRoutes = [];

        // Check if file exists ...
        if (true === $this->getRegistry()->getFilesystem()->readable($filename)) {
            include $filename;

            $content = file_get_contents($filename);
            $matches = preg_match('/class\s([A-Za-z\_]+)/', $content, $classes);

            // Process all found classes ...
            if ($matches > 0) {

                // Use our selection from result
                $className = $classes[1];

                // Lookup for namespace ...
                $namespaceCount = preg_match('#^namespace\s+(.+?);$#sm', $content, $namespace);

                // Extract namespace of file/class if found ...
                if ($namespaceCount > 0) {
                    $namespace = $namespace[1].'\\';
                } else {
                    $namespace = '';
                }

                // Combine everything to a full qualified className ...
                $fullQualifiedClassName = $namespace.$className;

                $reflection = new ReflectionClass($fullQualifiedClassName);

                // Extract the methods (potentially an ...Action())
                $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);

                foreach ($methods as $key => $reflection) {
                    if (preg_match('/(Action)$/ui', $reflection->name)) {
                        if (isset($actionsWithRoutes[$filename]) === false) {
                            $actionsWithRoutes[$filename] = [];
                        }

                        $actionsWithRoutes[$filename][$reflection->name] =
                            $this->getAnnotationReader()->getMethodAnnotations($reflection);
                    }
                }
            }

            $routes = $this->sortRoutes($actionsWithRoutes);
        }

        return $routes;
    }
protected function parseRoutesFromFile ( $ filename ) { // Assume empty result $ routes = [ ] ; $ actionsWithRoutes = [ ] ; // Check if file exists ... if ( true === $ this -> getRegistry ( ) -> getFilesystem ( ) -> readable ( $ filename ) ) { include $ filename ; $ content = file_get_contents ( $ filename ) ; $ matches = preg_match ( '/class\s([A-Za-z\_]+)/' , $ content , $ classes ) ; // Process all found classes ... if ( $ matches > 0 ) { // Use our selection from result $ className = $ classes [ 1 ] ; // Lookup for namespace ... $ namespaceCount = preg_match ( '#^namespace\s+(.+?);$#sm' , $ content , $ namespace ) ; // Extract namespace of file/class if found ... if ( $ namespaceCount > 0 ) { $ namespace = $ namespace [ 1 ] . '\\' ; } else { $ namespace = '' ; } // Combine everything to a full qualified className ... $ fullQualifiedClassName = $ namespace . $ className ; $ reflection = new ReflectionClass ( $ fullQualifiedClassName ) ; // Extract the methods (potentially an ...Action()) $ methods = $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; foreach ( $ methods as $ key => $ reflection ) { if ( preg_match ( '/(Action)$/ui' , $ reflection -> name ) ) { if ( isset ( $ actionsWithRoutes [ $ filename ] ) === false ) { $ actionsWithRoutes [ $ filename ] = [ ] ; } $ actionsWithRoutes [ $ filename ] [ $ reflection -> name ] = $ this -> getAnnotationReader ( ) -> getMethodAnnotations ( $ reflection ) ; } } } $ routes = $ this -> sortRoutes ( $ actionsWithRoutes ) ; } return $ routes ; }
Parses the routes from filename.

@param string $filename The filename to parse routes from.

@author Benjamin Carl <opensource@clickalicious.de>

@return array Routes from file ordered and ready for further use
Parses the routes from filename .