Completed
Push — master ( 944dfb...9c93d5 )
by Thomas
10:01 queued 37s
created

GroupActionUpdateAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 7
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureParams() 0 3 1
A run() 0 11 2
1
<?php
2
namespace keeko\core\action;
3
4
use keeko\framework\foundation\AbstractAction;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
use phootwork\json\Json;
9
use Tobscure\JsonApi\Exception\InvalidParameterException;
10
use keeko\core\domain\GroupDomain;
11
12
/**
13
 * Updates the relationship of group to action
14
 * 
15
 * This code is automatically created. Modifications will probably be overwritten.
16
 * 
17
 * @author gossi
18
 */
19
class GroupActionUpdateAction extends AbstractAction {
20
21
	/**
22
	 * @param OptionsResolver $resolver
23
	 */
24
	public function configureParams(OptionsResolver $resolver) {
25
		$resolver->setRequired(['id']);
26
	}
27
28
	/**
29
	 * Automatically generated run method
30
	 * 
31
	 * @param Request $request
32
	 * @return Response
33
	 */
34
	public function run(Request $request) {
35
		$body = Json::decode($request->getContent());
36
		if (!isset($body['data'])) {
37
			throw new InvalidParameterException();
38
		}
39
		$data = $body['data'];
40
		$id = $this->getParam('id');
41
		$domain = new GroupDomain($this->getServiceContainer());
42
		$payload = $domain->updateAction($id, $data);
43
		return $this->responder->run($request, $payload);
44
	}
45
}
46