1
|
|
|
<?php |
2
|
|
|
namespace rtens\domin\delivery\web\adapters\curir\root; |
3
|
|
|
|
4
|
|
|
use rtens\domin\delivery\web\adapters\curir\CurirBreadCrumbsTrail; |
5
|
|
|
use rtens\domin\delivery\web\adapters\curir\CurirParameterReader; |
6
|
|
|
use rtens\domin\delivery\web\resources\ExecutionResource; |
7
|
|
|
use rtens\domin\delivery\web\WebApplication; |
8
|
|
|
use watoki\curir\cookie\CookieStore; |
9
|
|
|
use watoki\curir\delivery\WebRequest; |
10
|
|
|
use watoki\curir\Resource; |
11
|
|
|
|
12
|
|
|
class ExecuteResource extends Resource { |
13
|
|
|
|
14
|
|
|
const ACTION_ARG = '__action'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param WebApplication $app <- |
18
|
|
|
* @param CookieStore $cookies <- |
19
|
|
|
* @param WebRequest $request <- |
20
|
|
|
* @param string $__action |
21
|
|
|
* @param bool $__force |
22
|
|
|
* @return string |
23
|
|
|
*/ |
24
|
|
|
public function doGet(WebApplication $app, CookieStore $cookies, WebRequest $request, $__action, $__force = false) { |
25
|
|
|
$execution = $this->getExecutionResource($app, $cookies, $request); |
26
|
|
|
return $execution->handleGet($__action, $__force); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param WebApplication $app <- |
31
|
|
|
* @param CookieStore $cookies <- |
32
|
|
|
* @param WebRequest $request <- |
33
|
|
|
* @param string $__action |
34
|
|
|
* @return string |
35
|
|
|
*/ |
36
|
|
|
public function doPost(WebApplication $app, CookieStore $cookies, WebRequest $request, $__action) { |
37
|
|
|
$execution = $this->getExecutionResource($app, $cookies, $request); |
38
|
|
|
return $execution->handlePost($__action); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
private function getExecutionResource(WebApplication $app, CookieStore $cookies, WebRequest $request) { |
42
|
|
|
$app->prepare(); |
43
|
|
|
|
44
|
|
|
$reader = new CurirParameterReader($request); |
45
|
|
|
return new ExecutionResource($app, $reader, new CurirBreadCrumbsTrail($reader, $cookies)); |
46
|
|
|
} |
47
|
|
|
} |