Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jan 24, 2019. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrontController.php
More file actions
Latest commit
76 lines (76 loc) · 2.04 KB
/
Copy pathFrontController.php
File metadata and controls
76 lines (76 loc) · 2.04 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespaceRedCat\Route;
useRedCat\Strategy\Di;
class FrontController implements \ArrayAccess{
protected$router;
protected$request;
protected$di;
protected$uri;
function__construct(Router$router, Request$request, Di$di=null){
$this->router = $router;
$this->request = $request;
$this->di = $di;
}
functiongetRoutes(){
return$this->router->getRoutes();
}
functiongetGroups(){
return$this->router->getGroups();
}
functionfind($uri,$server=null){
return$this->router->find($uri,$server);
}
functionmap($map,$index=0,$prepend=false,$group=null,$continue=false){
return$this->router->map($map,$index,$prepend,$group,$continue);
}
functionappend($match,$route=null,$index=0,$group=null,$continue=false){
return$this->router->append($match,$route,$index,$group,$continue);
}
functionprepend($match,$route=null,$index=0,$group=null,$continue=false){
return$this->router->prepend($match,$route,$index,$group,$continue);
}
functiongroup($group=null,$callback=null,$prepend=false){
return$this->router->group($group,$callback,$prepend);
}
functiongetUri(){
return$this->uri;
}
functionrun($uri,$domain=null){
$uri = ltrim($uri,'/');
$this->uri = $uri;
if($this->router->find($uri,$domain)){
$this->router->display();
returntrue;
}
}
functionoffsetSet($k,$v){
$this->router->offsetSet($k,$v);
}
functionoffsetGet($k){
$this->router->offsetGet($k);
}
functionoffsetExists($k){
$this->router->offsetExists($k);
}
functionoffsetUnset($k){
$this->router->offsetUnset($k);
}
functionrunFromGlobals(){
if(isset($_SERVER['REDCAT_URI'])){
$s = strlen($_SERVER['REDCAT_URI'])-1;
$p = strpos($_SERVER['REQUEST_URI'],'?');
if($p===false)
$path = substr($_SERVER['REQUEST_URI'],$s);
else
$path = substr($_SERVER['REQUEST_URI'],$s,$p-$s);
$path = urldecode($path);
}
else{
$path = isset($_SERVER['PATH_INFO'])?$_SERVER['PATH_INFO']:'';
}
return$this->run($path,$_SERVER['SERVER_NAME']);
}
function__invoke($uri,$domain=null){
return$this->run($uri,$domain);
}
}