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\Currency; |
10
|
|
|
use Tobscure\JsonApi\Document; |
11
|
|
|
use Tobscure\JsonApi\Resource; |
12
|
|
|
use Tobscure\JsonApi\Parameters; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Automatically generated JsonResponder for Reads a currency |
16
|
|
|
* |
17
|
|
|
* @author gossi |
18
|
|
|
*/ |
19
|
|
|
class CurrencyReadJsonResponder extends AbstractPayloadResponder { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param Request $request |
23
|
|
|
* @param PayloadInterface $payload |
24
|
|
|
*/ |
25
|
|
|
public function found(Request $request, PayloadInterface $payload) { |
26
|
|
|
$params = new Parameters($request->query->all()); |
27
|
|
|
$serializer = Currency::getSerializer(); |
28
|
|
|
$resource = new Resource($payload->getModel(), $serializer); |
|
|
|
|
29
|
|
|
$resource = $resource->with($params->getInclude([])); |
30
|
|
|
$resource = $resource->fields($params->getFields([ |
|
|
|
|
31
|
|
|
'currency' => Currency::getSerializer()->getFields() |
32
|
|
|
])); |
33
|
|
|
$document = new Document($resource); |
34
|
|
|
|
35
|
|
|
return new JsonResponse($document->toArray(), 200); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param Request $request |
40
|
|
|
* @param PayloadInterface $payload |
41
|
|
|
*/ |
42
|
|
|
public function notFound(Request $request, PayloadInterface $payload) { |
|
|
|
|
43
|
|
|
throw new ResourceNotFoundException($payload->getMessage()); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
*/ |
48
|
|
|
protected function getPayloadMethods() { |
49
|
|
|
return [ |
50
|
|
|
'keeko\framework\domain\payload\Found' => 'found', |
51
|
|
|
'keeko\framework\domain\payload\NotFound' => 'notFound' |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
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.