1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace Jaxon\App; |
4
|
|
|
|
5
|
|
|
use Jaxon\App\Session\SessionInterface; |
6
|
|
|
use Jaxon\App\View\ViewRenderer; |
7
|
|
|
use Jaxon\Exception\SetupException; |
8
|
|
|
use Jaxon\Plugin\Request\CallableClass\CallableClassHelper; |
9
|
|
|
use Jaxon\Plugin\Response\DataBag\DataBagContext; |
10
|
|
|
use Jaxon\Plugin\Response\JQuery\DomSelector; |
11
|
|
|
use Jaxon\Request\Factory\RequestFactory; |
12
|
|
|
use Jaxon\Request\TargetInterface; |
13
|
|
|
use Jaxon\Response\Response; |
14
|
|
|
use Psr\Log\LoggerInterface; |
15
|
|
|
|
16
|
|
|
class CallableClass |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var Response |
20
|
|
|
*/ |
21
|
|
|
protected $response = null; |
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var CallableClassHelper |
25
|
|
|
*/ |
26
|
|
|
protected $xCallableClassHelper = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Get the Jaxon request target |
30
|
|
|
* |
31
|
|
|
* @return TargetInterface |
32
|
|
|
*/ |
33
|
|
|
protected function target(): TargetInterface |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
return $this->xCallableClassHelper->xTarget; |
36
|
|
|
} |
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get an instance of a Jaxon class by name |
40
|
|
|
* |
41
|
|
|
* @param string $sName the class name |
42
|
|
|
* |
43
|
|
|
* @return object|null |
44
|
|
|
* @throws SetupException |
45
|
|
|
*/ |
46
|
|
|
public function cl(string $sName) |
47
|
|
|
{ |
48
|
|
|
$xCallableClass = $this->xCallableClassHelper->xCallableRegistry->getCallableObject($sName); |
49
|
|
|
if($xCallableClass === null) |
50
|
|
|
{ |
51
|
|
|
return null; |
52
|
|
|
} |
53
|
|
|
return $xCallableClass->getRegisteredObject(); |
54
|
|
|
} |
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get the request factory. |
58
|
|
|
* |
59
|
|
|
* @return RequestFactory |
60
|
|
|
*/ |
61
|
|
|
public function rq(): RequestFactory |
62
|
|
|
{ |
63
|
|
|
return $this->xCallableClassHelper->xRequestFactory; |
64
|
|
|
} |
|
|
|
|
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the logger |
68
|
|
|
* |
69
|
|
|
* @return LoggerInterface |
70
|
|
|
*/ |
71
|
|
|
public function logger(): LoggerInterface |
72
|
|
|
{ |
73
|
|
|
return $this->xCallableClassHelper->xLogger; |
74
|
|
|
} |
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the view renderer |
78
|
|
|
* |
79
|
|
|
* @return ViewRenderer |
80
|
|
|
*/ |
81
|
|
|
public function view(): ViewRenderer |
82
|
|
|
{ |
83
|
|
|
return $this->xCallableClassHelper->xViewRenderer; |
84
|
|
|
} |
|
|
|
|
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get the session manager |
88
|
|
|
* |
89
|
|
|
* @return SessionInterface |
90
|
|
|
*/ |
91
|
|
|
public function session(): SessionInterface |
92
|
|
|
{ |
93
|
|
|
return $this->xCallableClassHelper->xSessionManager; |
94
|
|
|
} |
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Get the uploaded files |
98
|
|
|
* |
99
|
|
|
* @return array |
100
|
|
|
*/ |
101
|
|
|
public function files(): array |
102
|
|
|
{ |
103
|
|
|
return $this->xCallableClassHelper->xUploadHandler->files(); |
104
|
|
|
} |
|
|
|
|
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Create a JQuery DomSelector, and link it to the response attribute. |
108
|
|
|
* |
109
|
|
|
* @param string $sPath The jQuery selector path |
110
|
|
|
* @param string $sContext A context associated to the selector |
|
|
|
|
111
|
|
|
* |
112
|
|
|
* @return DomSelector |
113
|
|
|
*/ |
114
|
|
|
public function jq(string $sPath = '', string $sContext = ''): DomSelector |
115
|
|
|
{ |
116
|
|
|
return $this->response->jq($sPath, $sContext); |
117
|
|
|
} |
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Get a data bag. |
121
|
|
|
* |
122
|
|
|
* @param string $sName |
|
|
|
|
123
|
|
|
* |
124
|
|
|
* @return DataBagContext |
125
|
|
|
*/ |
126
|
|
|
public function bag(string $sName): DataBagContext |
127
|
|
|
{ |
128
|
|
|
return $this->response->bag($sName); |
129
|
|
|
} |
|
|
|
|
130
|
|
|
} |
131
|
|
|
|