|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jaxon\App; |
|
4
|
|
|
|
|
5
|
|
|
use Jaxon\Di\Container; |
|
6
|
|
|
use Jaxon\App\Session\SessionInterface; |
|
7
|
|
|
use Jaxon\App\Stash\Stash; |
|
8
|
|
|
use Jaxon\App\View\ViewRenderer; |
|
9
|
|
|
use Jaxon\Exception\SetupException; |
|
10
|
|
|
use Jaxon\Script\JxnCall; |
|
11
|
|
|
use Jaxon\Plugin\Request\CallableClass\CallableClassHelper; |
|
12
|
|
|
use Jaxon\Plugin\Response\DataBag\DataBagContext; |
|
13
|
|
|
use Jaxon\Request\TargetInterface; |
|
14
|
|
|
use Jaxon\Response\AjaxResponse; |
|
15
|
|
|
use Psr\Log\LoggerInterface; |
|
16
|
|
|
|
|
17
|
|
|
abstract class AbstractCallable |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var CallableClassHelper |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $xHelper = null; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Initialize the callable class |
|
26
|
|
|
* |
|
27
|
|
|
* @param Container $di |
|
28
|
|
|
* @param CallableClassHelper $xHelper |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
abstract public function _initCallable(Container $di, CallableClassHelper $xHelper); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Get the Ajax response |
|
36
|
|
|
* |
|
37
|
|
|
* @return AjaxResponse |
|
38
|
|
|
*/ |
|
39
|
|
|
abstract protected function _response(): AjaxResponse; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Get the Jaxon request target |
|
43
|
|
|
* |
|
44
|
|
|
* @return TargetInterface |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function target(): TargetInterface |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->xHelper->xTarget; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Get the temp cache |
|
53
|
|
|
* |
|
54
|
|
|
* @return Stash |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function stash(): Stash |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->xHelper->xStash; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get an instance of a Jaxon class by name |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $sClassName the class name |
|
65
|
|
|
* |
|
66
|
|
|
* @return mixed |
|
67
|
|
|
* @throws SetupException |
|
68
|
|
|
*/ |
|
69
|
|
|
public function cl(string $sClassName) |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->xHelper->cl($sClassName); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Get the js call factory. |
|
76
|
|
|
* |
|
77
|
|
|
* @param string $sClassName |
|
78
|
|
|
* |
|
79
|
|
|
* @return JxnCall |
|
80
|
|
|
*/ |
|
81
|
|
|
public function rq(string $sClassName = ''): JxnCall |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->xHelper->rq($sClassName); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Get the logger |
|
88
|
|
|
* |
|
89
|
|
|
* @return LoggerInterface |
|
90
|
|
|
*/ |
|
91
|
|
|
public function logger(): LoggerInterface |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->xHelper->xLogger; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Get the view renderer |
|
98
|
|
|
* |
|
99
|
|
|
* @return ViewRenderer |
|
100
|
|
|
*/ |
|
101
|
|
|
public function view(): ViewRenderer |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->xHelper->xViewRenderer; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get the session manager |
|
108
|
|
|
* |
|
109
|
|
|
* @return SessionInterface |
|
110
|
|
|
*/ |
|
111
|
|
|
public function session(): SessionInterface |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->xHelper->xSessionManager; |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Get the uploaded files |
|
118
|
|
|
* |
|
119
|
|
|
* @return array |
|
120
|
|
|
*/ |
|
121
|
|
|
public function files(): array |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->xHelper->xUploadHandler->files(); |
|
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Get a data bag. |
|
128
|
|
|
* |
|
129
|
|
|
* @param string $sBagName |
|
130
|
|
|
* |
|
131
|
|
|
* @return DataBagContext |
|
132
|
|
|
*/ |
|
133
|
|
|
public function bag(string $sBagName): DataBagContext |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->_response()->bag($sBagName); |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|