private static function findRoute() { foreach (self::$routes as $route => $action) { if (gettype($route) == 'integer') { $route = $action; } $regEx = self::routeToRegEx($route); if (preg_match($regEx[0], self::$requestUrl, $matches)) { self::$currentRoute = [$route, explode('@', $action)]; $params = array_slice($matches, 1); for ($i = 0; $i < 2; ++$i) { $pos = $regEx[1][$i]; if ($pos !== null) { self::$currentRoute[1][$i] = $params[$pos]; unset($params[$pos]); } } $params = array_values($params); self::startRoute($params); break; } } if (!self::$currentRoute) { self::error404(); } }
public static function group($prop, callable $callable) { self::$prefixUrl = isset($prop['Prefix']) ? $prop['Prefix'] : ''; if (isset($prop['Middleware'])) { if (is_array($prop['Middleware'])) { self::$middleware = $prop['Middleware']; } else { self::$middleware = [$prop['Middleware']]; } } $callable(new self()); self::$prefixUrl = ''; self::$middleware = []; }
public static function make() { return self::$instance = new Route(); }
<?php $id = $_POST['id']; $value = $_POST['value']; $lang = $_POST['lang']; ControllerPhp::$language = $lang; SystemRoute::ROW($id)->setDescription($value);
<?php echo SystemRoute::ROW(Config::get('DEFAULT_PAGE'))->getPath(true);
$purl = parse_url($url); $path = explode('/', $purl['path']); array_shift($path); $default_language = Config::get('DEFAULT_LANGUAGE'); $available_languages = explode(',', Config::get('AVAILABLE_LANGUAGES')); if ($path[0] != $default_language && in_array($path[0], $available_languages)) { $language = $path[0]; array_shift($path); } else { $language = $default_language; } $result['lang'] = $language; // Determino el nodo en el que empiezo a buscar: $node = SystemRoute::ROW(Config::get('DEFAULT_PAGE')); if (count($path) && $node->getChildByUrl($path[0]) === null) { $root = SystemRoute::getRoot(); $root_child = $root->getChildByUrl($path[0]); if ($root->getChildByUrl($path[0]) !== null && $root_child->getId() != $node->getId()) { $node = $root; } } // Busco las rutas a partir del nodo elegido: $new_node = $node; while (count($path) && !is_null($new_node)) { $new_node = $new_node->getChildByUrl($path[0]); if (!is_null($new_node)) { $node = $new_node; array_shift($path); } } ControllerPhp::$language = $language;
<?php $id = $_POST['id']; $value = $_POST['value']; $lang = $_POST['lang']; ControllerPhp::$language = $lang; SystemRoute::ROW($id)->setTitle($value);