1
|
|
|
<?php |
2
|
|
|
namespace keeko\core\responder; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\HttpFoundation\Request; |
5
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
6
|
|
|
use keeko\framework\domain\payload\PayloadInterface; |
7
|
|
|
use keeko\framework\foundation\AbstractPayloadResponder; |
8
|
|
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException; |
9
|
|
|
use keeko\core\model\Action; |
10
|
|
|
use keeko\core\model\Module; |
11
|
|
|
use keeko\core\model\Group; |
12
|
|
|
use Tobscure\JsonApi\Document; |
13
|
|
|
use Tobscure\JsonApi\Resource; |
14
|
|
|
use Tobscure\JsonApi\Parameters; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Automatically generated JsonResponder for Reads an action |
18
|
|
|
* |
19
|
|
|
* @author gossi |
20
|
|
|
*/ |
21
|
|
|
class ActionReadJsonResponder extends AbstractPayloadResponder { |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param Request $request |
25
|
|
|
* @param PayloadInterface $payload |
26
|
|
|
*/ |
27
|
|
|
public function found(Request $request, PayloadInterface $payload) { |
28
|
|
|
$params = new Parameters($request->query->all()); |
29
|
|
|
$serializer = Action::getSerializer(); |
30
|
|
|
$resource = new Resource($payload->getModel(), $serializer); |
|
|
|
|
31
|
|
|
$resource = $resource->with($params->getInclude(['module', 'groups'])); |
32
|
|
|
$resource = $resource->fields($params->getFields([ |
|
|
|
|
33
|
|
|
'action' => Action::getSerializer()->getFields(), |
34
|
|
|
'module' => Module::getSerializer()->getFields(), |
35
|
|
|
'groups' => Group::getSerializer()->getFields() |
36
|
|
|
])); |
37
|
|
|
$document = new Document($resource); |
38
|
|
|
|
39
|
|
|
return new JsonResponse($document->toArray(), 200); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param Request $request |
44
|
|
|
* @param PayloadInterface $payload |
45
|
|
|
*/ |
46
|
|
|
public function notFound(Request $request, PayloadInterface $payload) { |
|
|
|
|
47
|
|
|
throw new ResourceNotFoundException($payload->getMessage()); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
*/ |
52
|
|
|
protected function getPayloadMethods() { |
53
|
|
|
return [ |
54
|
|
|
'keeko\framework\domain\payload\Found' => 'found', |
55
|
|
|
'keeko\framework\domain\payload\NotFound' => 'notFound' |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.