private function loadRouteFile(&$routeTable, $fileName)
    {
        libxml_use_internal_errors(true);

        $xml = simplexml_load_file($fileName);

        if (empty($xml)) {
            $errorMessage = "Failed to parse XML route file: " . $fileName . "";

            foreach (libxml_get_errors() as $error) {
                $errorMessage .= "\n" . $error->message;
            }

            if (!empty($this->log))
            {
                $this->log->error($errorMessage);
            }
            return;
        }

        $routeClass = 'Slab\Router\Route';

        if (empty($routeClass)) {
            if (!empty($this->log))
            {
                $this->log->error("Failed to find suitable Route object.");
            }
            return;
        }

        foreach ($xml->xpath('route') as $routeObject) {
            /**
             * @var \Slab\Router\Route $route
             */
            try
            {
                $route = new $routeClass($routeObject);
            }
            catch (\Exception $exception)
            {
                if (!empty($this->log))
                {
                    $this->log->error("Failed to add route to table: " . $exception->getMessage());
                }
                continue;
            }


            if (!$route->isValid()) {
                $this->addDebugMessage('Skipping invalid route!');
                continue;
            }

            $path = $route->getRoutingPath();

            //Here we'll iterate through the current routing tree on $currentLevel checking static routes
            if ($path) {
                $currentLevel =& $routeTable;
                //$pathDepth = count($path);

                //Loop through each path level and add that level of hierarchy to our routing table
                foreach ($path as $pathFolder) {
                    if (empty($currentLevel[$pathFolder])) {
                        $currentLevel[$pathFolder] = array();
                    }

                    $currentLevel =& $currentLevel[$pathFolder];
                }

                if (!empty($currentLevel)) {
                    //Check each item in this list's pattern string against the one we currently have.
                    //If a pattern string matches (empty or not) that means we have an overridden path

                    $overridden = false;
                    foreach ($currentLevel as $index => $subRoute) {
                        if (($subRoute instanceof \Slab\Router\Route) &&
                            ($subRoute->getPatternString() == $route->getPatternString())
                        ) {
                            $currentLevel[$index] = $route;
                            $overridden = true;
                        }
                    }

                    if (!$overridden) {
                        $currentLevel[] = $route;
                    }
                } else {
                    $currentLevel[] = $route;
                }
            } else {
                $routeTable['/'][] = $route;
            }
        }
    }
private function loadRouteFile(&$routeTable, $fileName)
    {
        libxml_use_internal_errors(true);

        $xml = simplexml_load_file($fileName);

        if (empty($xml)) {
            $errorMessage = "Failed to parse XML route file: " . $fileName . "";

            foreach (libxml_get_errors() as $error) {
                $errorMessage .= "\n" . $error->message;
            }

            if (!empty($this->log))
            {
                $this->log->error($errorMessage);
            }
            return;
        }

        $routeClass = 'Slab\Router\Route';

        if (empty($routeClass)) {
            if (!empty($this->log))
            {
                $this->log->error("Failed to find suitable Route object.");
            }
            return;
        }

        foreach ($xml->xpath('route') as $routeObject) {
            /**
             * @var \Slab\Router\Route $route
             */
            try
            {
                $route = new $routeClass($routeObject);
            }
            catch (\Exception $exception)
            {
                if (!empty($this->log))
                {
                    $this->log->error("Failed to add route to table: " . $exception->getMessage());
                }
                continue;
            }


            if (!$route->isValid()) {
                $this->addDebugMessage('Skipping invalid route!');
                continue;
            }

            $path = $route->getRoutingPath();

            //Here we'll iterate through the current routing tree on $currentLevel checking static routes
            if ($path) {
                $currentLevel =& $routeTable;
                //$pathDepth = count($path);

                //Loop through each path level and add that level of hierarchy to our routing table
                foreach ($path as $pathFolder) {
                    if (empty($currentLevel[$pathFolder])) {
                        $currentLevel[$pathFolder] = array();
                    }

                    $currentLevel =& $currentLevel[$pathFolder];
                }

                if (!empty($currentLevel)) {
                    //Check each item in this list's pattern string against the one we currently have.
                    //If a pattern string matches (empty or not) that means we have an overridden path

                    $overridden = false;
                    foreach ($currentLevel as $index => $subRoute) {
                        if (($subRoute instanceof \Slab\Router\Route) &&
                            ($subRoute->getPatternString() == $route->getPatternString())
                        ) {
                            $currentLevel[$index] = $route;
                            $overridden = true;
                        }
                    }

                    if (!$overridden) {
                        $currentLevel[] = $route;
                    }
                } else {
                    $currentLevel[] = $route;
                }
            } else {
                $routeTable['/'][] = $route;
            }
        }
    }
private function loadRouteFile ( & $ routeTable , $ fileName ) { libxml_use_internal_errors ( true ) ; $ xml = simplexml_load_file ( $ fileName ) ; if ( empty ( $ xml ) ) { $ errorMessage = "Failed to parse XML route file: " . $ fileName . "" ; foreach ( libxml_get_errors ( ) as $ error ) { $ errorMessage .= "\n" . $ error -> message ; } if ( ! empty ( $ this -> log ) ) { $ this -> log -> error ( $ errorMessage ) ; } return ; } $ routeClass = 'Slab\Router\Route' ; if ( empty ( $ routeClass ) ) { if ( ! empty ( $ this -> log ) ) { $ this -> log -> error ( "Failed to find suitable Route object." ) ; } return ; } foreach ( $ xml -> xpath ( 'route' ) as $ routeObject ) { /**
             * @var \Slab\Router\Route $route
             */ try { $ route = new $ routeClass ( $ routeObject ) ; } catch ( \ Exception $ exception ) { if ( ! empty ( $ this -> log ) ) { $ this -> log -> error ( "Failed to add route to table: " . $ exception -> getMessage ( ) ) ; } continue ; } if ( ! $ route -> isValid ( ) ) { $ this -> addDebugMessage ( 'Skipping invalid route!' ) ; continue ; } $ path = $ route -> getRoutingPath ( ) ; //Here we'll iterate through the current routing tree on $currentLevel checking static routes if ( $ path ) { $ currentLevel = & $ routeTable ; //$pathDepth = count($path); //Loop through each path level and add that level of hierarchy to our routing table foreach ( $ path as $ pathFolder ) { if ( empty ( $ currentLevel [ $ pathFolder ] ) ) { $ currentLevel [ $ pathFolder ] = array ( ) ; } $ currentLevel = & $ currentLevel [ $ pathFolder ] ; } if ( ! empty ( $ currentLevel ) ) { //Check each item in this list's pattern string against the one we currently have. //If a pattern string matches (empty or not) that means we have an overridden path $ overridden = false ; foreach ( $ currentLevel as $ index => $ subRoute ) { if ( ( $ subRoute instanceof \ Slab \ Router \ Route ) && ( $ subRoute -> getPatternString ( ) == $ route -> getPatternString ( ) ) ) { $ currentLevel [ $ index ] = $ route ; $ overridden = true ; } } if ( ! $ overridden ) { $ currentLevel [ ] = $ route ; } } else { $ currentLevel [ ] = $ route ; } } else { $ routeTable [ '/' ] [ ] = $ route ; } } }
Load an XML route file from a fully qualified path name

@param array $routeTable
@param string $fileName
Load an XML route file from a fully qualified path name