Commit 30211ade authored by Lukáš Bachleda's avatar Lukáš Bachleda

Router controler

parent 07dc77a1
Pipeline #21903 canceled with stages
......@@ -6,6 +6,24 @@ class RouterController extends Controller
protected $controller;
public function process($params) {
$parsedUrl = $this->parseUrl($params[0]);
$classController = $this->toCamelCase(array_shift($parsedUrl)) . 'Controller';
}
private function parseUrl($url) {
$parsedUrl = parse_url($url);
$parsedUrl["path"] = ltrim($parsedUrl["path"], "/");
$parsedUrl["path"] = trim($parsedUrl["path"]);
$explodedRoutes = explode("/", $parsedUrl["path"]);
return $explodedRoutes;
}
private function toCamelCase($text)
{
$words = str_replace('-', ' ', $text);
$words = ucwords($words);
$words = str_replace(' ', '', $words);
return $words;
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment