20 if(isset($array[
"controller"])){
23 $this->methods=\array_keys($array);
30 $this->controller=$array[
"controller"];
31 $this->action=$array[
"action"];
32 $this->name=$array[
"name"];
33 $this->cache=$array[
"cache"];
34 $this->duration=$array[
"duration"];
35 if(isset($array[
"parameters"]) && \
sizeof($array[
"parameters"])>0){
36 if(\class_exists($this->controller)){
37 if(\method_exists($this->controller, $this->action)){
38 $method=new \ReflectionMethod($this->controller,$this->action);
39 $params=$method->getParameters();
40 foreach ($array[
"parameters"] as $paramIndex){
41 if($paramIndex===
"*"){
44 $this->parameters[]=
"...".$pName;
47 $index=\intval(\str_replace(
"~",
"", $paramIndex));
48 if(isset($params[$index])){
49 if(\substr($paramIndex,0,1)===
"~")
50 $this->parameters[]=$params[$index]->getName();
52 $this->parameters[]=$params[$index]->getName().
"*";
57 $this->messages[]=
"The method <b>".$this->action.
"</b> does not exists in the class <b>".$this->controller.
"</b>.\n";
60 $this->messages[
$this->controller]=
"The class <b>".$this->controller.
"</b> does not exist.\n";
66 if($param->isVariadic()){
67 return $param->getName();
137 return " (".((\is_array($this->parameters))?\implode(
", ", $this->parameters):
$this->parameters).
")";
140 public static function init($array){
142 foreach ($array as $k=>$v){
143 $result[]=
new Route($k, $v);
__construct($path="", $array=[])
setParameters($parameters)
getVariadicParam($parameters)
setController($controller)