/** * Constructor */ public function __construct() { $fun = function () { ob_start(); //$myBlogApp::run(); return ob_get_clean(); }; parent::__construct('^/blog$', $fun); }
/** * Returns routing result - array with params (module, controller, action). * Tries to match requested URI with all added routes. * If matches weren't found default route is used. * * @throws Redirect404Exception * @return array */ public function route() { foreach ($this->staticRoutes as $route) { if ($route->match($this->uri)) { $this->usedRoute = $route; return $route->getDispatchAttrs(); } } foreach ($this->routes as $route) { if ($route->match($this->uri)) { $this->usedRoute = $route; return $route->getDispatchAttrs(); } } return $this->defaultRoute->getDispatchAttrs($this->uri); }
} } function diverse_array($vector) { $result = array(); foreach ($vector as $key1 => $value1) { foreach ($value1 as $key2 => $value2) { $result[$key2][$key1] = $value2; } } return $result; } function endsWith($haystack, $needle) { $length = strlen($needle); if ($length == 0) { return true; } return substr($haystack, -$length) === $needle; } } $url = $_GET[Runtime::$PARAMS_QUERY]; if (isset($url) && !is_null($url) && $url != "") { new Runtime($url); } else { include_once 'Route.php'; include_once 'App/Route/DefaultRoute.php'; $route = new DefaultRoute(); $route->setClientsAddress($_SERVER['REMOTE_ADDR']); new Runtime($route->getDefaultPath()); }