public function add(Route $route): self
    {
        if ($route->uri === ""
            || $route->method === 0b0
            || $route->action === null) {
            $this->logger->error("Route incomplete. Unable to add");
            $this->logger->debug("Incomplete Route", [$route]);
            throw new Exception\RouteIncompleteException(
                "Retrieved Route is not complete and can not be stored"
            );
        }

        // store default route
        if ($route->isDefault) {
            if ($this->defaultRoute === null) {
                $this->defaultRoute = $route;
            } else {
                $this->logger->debug(
                    "Default route already added to container, skipping add.",
                    ["route" => $route, "storedDefault" => $this->defaultRoute]
                );
            }
        }

        // store 404 route
        if ($route->is404) {
            if ($this->e404Route === null) {
                $this->e404Route = $route;
                $this->logger->info("404 route added to Route Container");
            } else {
                $this->logger->debug(
                    "404 route already added to container, skipping add.",
                    ["route" => $route, "stored404" => $this->e404Route]
                );
            }

            return $this;
        }

        // store route to regular container
        $this->routes[] = $route;

        $this->logger->info(
            "Route successfully added to Container",
            ["uri" => $route->uri]
        );

        return $this;
    }
public function add(Route $route): self
    {
        if ($route->uri === ""
            || $route->method === 0b0
            || $route->action === null) {
            $this->logger->error("Route incomplete. Unable to add");
            $this->logger->debug("Incomplete Route", [$route]);
            throw new Exception\RouteIncompleteException(
                "Retrieved Route is not complete and can not be stored"
            );
        }

        // store default route
        if ($route->isDefault) {
            if ($this->defaultRoute === null) {
                $this->defaultRoute = $route;
            } else {
                $this->logger->debug(
                    "Default route already added to container, skipping add.",
                    ["route" => $route, "storedDefault" => $this->defaultRoute]
                );
            }
        }

        // store 404 route
        if ($route->is404) {
            if ($this->e404Route === null) {
                $this->e404Route = $route;
                $this->logger->info("404 route added to Route Container");
            } else {
                $this->logger->debug(
                    "404 route already added to container, skipping add.",
                    ["route" => $route, "stored404" => $this->e404Route]
                );
            }

            return $this;
        }

        // store route to regular container
        $this->routes[] = $route;

        $this->logger->info(
            "Route successfully added to Container",
            ["uri" => $route->uri]
        );

        return $this;
    }
public function add ( Route $ route ) : self { if ( $ route -> uri === "" || $ route -> method === 0b0 || $ route -> action === null ) { $ this -> logger -> error ( "Route incomplete. Unable to add" ) ; $ this -> logger -> debug ( "Incomplete Route" , [ $ route ] ) ; throw new Exception \ RouteIncompleteException ( "Retrieved Route is not complete and can not be stored" ) ; } // store default route if ( $ route -> isDefault ) { if ( $ this -> defaultRoute === null ) { $ this -> defaultRoute = $ route ; } else { $ this -> logger -> debug ( "Default route already added to container, skipping add." , [ "route" => $ route , "storedDefault" => $ this -> defaultRoute ] ) ; } } // store 404 route if ( $ route -> is404 ) { if ( $ this -> e404Route === null ) { $ this -> e404Route = $ route ; $ this -> logger -> info ( "404 route added to Route Container" ) ; } else { $ this -> logger -> debug ( "404 route already added to container, skipping add." , [ "route" => $ route , "stored404" => $ this -> e404Route ] ) ; } return $ this ; } // store route to regular container $ this -> routes [ ] = $ route ; $ this -> logger -> info ( "Route successfully added to Container" , [ "uri" => $ route -> uri ] ) ; return $ this ; }
Add Route definition

Add the retrieved Route to the internal Routes container array. If the
retrieved Route is not complete, throw the 'RouteIncompleteException'.

@param \SlaxWeb\Router\Route $route Route definition object
@return self
Add Route definition