1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Anax\DI; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Anax base class implementing Dependency Injection / Service Locator |
7
|
|
|
* of the services used by the framework, using lazy loading. |
8
|
|
|
*/ |
9
|
|
|
class DIFactoryDefault extends DI |
10
|
|
|
{ |
11
|
|
|
//use \Anax\TLoadFile; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Construct. |
17
|
|
|
* |
18
|
|
|
*/ |
19
|
1 |
|
public function __construct() |
20
|
|
|
{ |
21
|
|
|
//parent::__construct(); |
22
|
|
|
|
23
|
|
|
//$this->loadFile("error_reporting.php"); |
24
|
|
|
|
25
|
1 |
|
$this->setShared("response", "\Anax\Response\CResponseBasic"); |
26
|
1 |
|
$this->setShared("validate", "\Anax\Validate\CValidate"); |
27
|
1 |
|
$this->setShared("flash", "\Anax\Flash\CFlashBasic"); |
28
|
1 |
|
$this->setShared("textFilter", "\Mos\TextFilter\CTextFilter"); |
29
|
|
|
|
30
|
1 |
|
$this->set("route", "\Anax\Route\CRouteBasic"); |
31
|
1 |
|
$this->set("view", "\Anax\View\CView"); |
32
|
|
|
|
33
|
|
|
$this->set("ErrorController", function () { |
34
|
|
|
$controller = new \Anax\MVC\ErrorController(); |
35
|
|
|
$controller->setDI($this); |
36
|
|
|
return $controller; |
37
|
1 |
|
}); |
38
|
|
|
|
39
|
|
|
$this->setShared("log", function () { |
40
|
|
|
$log = new \Anax\Log\CLogger(); |
41
|
|
|
$log->setContext("development"); |
42
|
|
|
return $log; |
43
|
1 |
|
}); |
44
|
|
|
|
45
|
|
|
$this->setShared("cache", function () { |
46
|
|
|
$cache = new \Anax\Cache\CFileCache(); |
47
|
|
|
$cache->configure("cache.php"); |
48
|
|
|
return $cache; |
49
|
1 |
|
}); |
50
|
|
|
|
51
|
|
|
$this->setShared("request", function () { |
52
|
|
|
$request = new \Anax\Request\CRequestBasic(); |
53
|
|
|
$request->init(); |
54
|
|
|
return $request; |
55
|
1 |
|
}); |
56
|
|
|
|
57
|
|
|
$this->setShared("url", function () { |
58
|
|
|
$url = new \Anax\Url\CUrl(); |
59
|
|
|
$url->configure("url.php"); |
60
|
|
|
$url->setSiteUrl($this->request->getSiteUrl()); |
|
|
|
|
61
|
|
|
$url->setBaseUrl($this->request->getBaseUrl()); |
|
|
|
|
62
|
|
|
$url->setStaticSiteUrl($this->request->getSiteUrl()); |
|
|
|
|
63
|
|
|
$url->setStaticBaseUrl($this->request->getBaseUrl()); |
|
|
|
|
64
|
|
|
$url->setScriptName($this->request->getScriptName()); |
|
|
|
|
65
|
|
|
$url->setDefaultsFromConfiguration(); |
66
|
|
|
return $url; |
67
|
1 |
|
}); |
68
|
|
|
|
69
|
|
|
$this->setShared("views", function () { |
70
|
|
|
$views = new \Anax\View\CViewContainer(); |
71
|
|
|
$views->configure("views.php"); |
72
|
|
|
$views->setDI($this); |
73
|
|
|
return $views; |
74
|
1 |
|
}); |
75
|
|
|
|
76
|
|
|
$this->setShared("router", function () { |
77
|
|
|
|
78
|
|
|
$router = new \Anax\Route\CRouterBasic(); |
79
|
|
|
$router->setDI($this); |
80
|
|
|
return $router; |
81
|
1 |
|
}); |
82
|
|
|
|
83
|
|
|
$this->setShared("dispatcher", function () { |
84
|
|
|
$dispatcher = new \Anax\MVC\CDispatcherBasic(); |
85
|
|
|
$dispatcher->setDI($this); |
86
|
|
|
return $dispatcher; |
87
|
1 |
|
}); |
88
|
|
|
|
89
|
|
|
$this->setShared("session", function () { |
90
|
|
|
$session = new \Anax\Session\CSession(); |
91
|
|
|
$session->configure("session.php"); |
92
|
|
|
$session->name(); |
93
|
|
|
$session->start(); |
94
|
|
|
return $session; |
95
|
1 |
|
}); |
96
|
|
|
|
97
|
|
|
$this->setShared("theme", function () { |
98
|
|
|
$themeEngine = new \Anax\ThemeEngine\CThemeEngine(); |
99
|
|
|
$themeEngine->setDI($this); |
100
|
|
|
$themeEngine->configure("theme.php"); |
101
|
|
|
return $themeEngine; |
102
|
1 |
|
}); |
103
|
|
|
|
104
|
|
|
$this->setShared("navbar", function () { |
105
|
|
|
$navbar = new \Anax\Navigation\CNavbar(); |
106
|
|
|
$navbar->setDI($this); |
107
|
|
|
$navbar->configure("navbar.php"); |
108
|
|
|
return $navbar; |
109
|
1 |
|
}); |
110
|
|
|
|
111
|
|
|
$this->set("fileContent", function () { |
112
|
|
|
$fc = new \Anax\Content\CFileContent(); |
113
|
|
|
$fc->setDI($this); |
114
|
|
|
$fc->configure("file_content.php"); |
115
|
|
|
return $fc; |
116
|
1 |
|
}); |
117
|
|
|
|
118
|
|
|
$this->set("pageContent", function () { |
119
|
|
|
$pc = new \Anax\Content\CPageContent(); |
120
|
|
|
$pc->setDI($this); |
121
|
|
|
$pc->configure("page_content.php"); |
122
|
|
|
return $pc; |
123
|
1 |
|
}); |
124
|
|
|
|
125
|
1 |
|
$this->setShared("content", function () { |
126
|
|
|
$content = new \Anax\Content\CFileBasedContent(); |
127
|
|
|
$content->setDI($this); |
128
|
|
|
$content->configure("content.php"); |
129
|
|
|
$content->setDefaultsFromConfiguration(); |
130
|
|
|
return $content; |
131
|
1 |
|
}); |
132
|
1 |
|
} |
133
|
|
|
} |
134
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.