/
Config.class.php
77 lines (43 loc) · 1.34 KB
/
Config.class.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
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
namespace apf\web\core\controller{
use \apf\core\Cmd;
use \apf\web\core\controller\Action;
use \apf\core\Directory as Dir;
use \apf\core\Config as BaseConfig;
use \apf\iface\web\Assetable as AssetableInterface;
use \apf\iface\web\Routeable as RouteableInterface;
class Config extends BaseConfig implements AssetableInterface,RouteableInterface{
//Adds assets method such as addAsset, getAsset, addJavascript, addCss, etc
use \apf\traits\web\Assetable;
use \apf\traits\web\Routeable;
public function setName($name){
$name = trim($name);
if(empty($name)){
throw new \InvalidArgumentException("Controller name can not be empty");
}
$this->name = $name;
return $this;
}
public function getName(){
return parent::getName();
}
public function addAction(Action $action){
$this->actions[$action->getName()] = $action;
return $this;
}
public function getAction($name){
if(!$this->hasAction($name)){
throw new \InvalidArgumentException("No action named \"$name\" could be found in this controller");
}
return $this->actions[$name];
}
public function getNonExportableAttributes(){
return Array(
'actions'
);
}
public function hasAction($name){
return array_key_exists($name,$this->actions);
}
}
}