-
Notifications
You must be signed in to change notification settings - Fork 0
/
Router.php
29 lines (28 loc) · 875 Bytes
/
Router.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace BlueSeed;
/**
* change the Request Class name e Method name to real Objects Definition
* using search replace for it
**/
class Router
{
private $request;
private $rc;
public function __construct(array $config, Request $req)
{
$this->request = $req;
$this->rc = $config;
}
public function resolve($language)
{
$classtoRoute = str_replace('Controller','',$this->request->getQuery(0));
$methotoRoute = $this->request->getQuery(1);
$dictionary = ($this->rc[$language]);
$route = strtolower($classtoRoute)."/".strtolower($methotoRoute);
if(array_key_exists($route,$dictionary)) {
$routeparts = explode("/",$dictionary[$route]);
$this->request->setController($routeparts[0]);
$this->request->setAction($routeparts[1]);
}
}
}