Completed
Push — master ( 94e820...3f0fe0 )
by Thomas
10:39
created

LocalizationExtLangJsonResponder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A notFound() 0 3 1
A notUpdated() 0 3 1
A read() 0 6 1
A getPayloadMethods() 0 8 1
1
<?php
2
namespace keeko\core\responder;
3
4
use Symfony\Component\HttpFoundation\Request;
5
use Symfony\Component\HttpFoundation\JsonResponse;
6
use keeko\framework\foundation\AbstractPayloadResponder;
7
use keeko\framework\domain\payload\NotFound;
8
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
9
use keeko\framework\domain\payload\Found;
10
use keeko\core\model\Localization;
11
use keeko\framework\domain\payload\NotUpdated;
12
13
/**
14
 * Automatically generated JsonResponder for Reads the relationship of localization to ext_lang
15
 * 
16
 * @author gossi
17
 */
18
class LocalizationExtLangJsonResponder extends AbstractPayloadResponder {
19
20
	/**
21
	 * @param Request $request
22
	 * @param NotFound $payload
23
	 */
24
	public function notFound(Request $request, NotFound $payload) {
25
		throw new ResourceNotFoundException($payload->getMessage());
26
	}
27
28
	/**
29
	 * @param Request $request
30
	 * @param NotUpdated $payload
31
	 */
32
	public function notUpdated(Request $request, NotUpdated $payload) {
33
		return new JsonResponse(null, 204);
34
	}
35
36
	/**
37
	 * @param Request $request
38
	 * @param Found $payload
39
	 */
40
	public function read(Request $request, Found $payload) {
41
		$serializer = Localization::getSerializer();
42
		$relationship = $serializer->extLang($payload->getModel());
43
44
		return new JsonResponse($relationship->toArray());
45
	}
46
47
	/**
48
	 */
49
	protected function getPayloadMethods() {
50
		return [
51
			'keeko\framework\domain\payload\NotFound' => 'notFound',
52
			'keeko\framework\domain\payload\NotValid' => 'notValid',
53
			'keeko\framework\domain\payload\Updated' => 'updated',
54
			'keeko\framework\domain\payload\NotUpdated' => 'notUpdated'
55
		];
56
	}
57
}
58