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

GroupActionRemoveAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 9
nc 2
nop 1
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
 * Removes action as relationship of group
14
 * 
15
 * This code is automatically created. Modifications will probably be overwritten.
16
 * 
17
 * @author gossi
18
 */
19
class GroupActionRemoveAction 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->removeAction($id, $data);
43
		return $this->responder->run($request, $payload);
44
	}
45
}
46