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

UserActivityAddAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
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\UserDomain;
11
12
/**
13
 * Adds activity as relationship to user
14
 * 
15
 * This code is automatically created. Modifications will probably be overwritten.
16
 * 
17
 * @author gossi
18
 */
19
class UserActivityAddAction 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 UserDomain($this->getServiceContainer());
42
		$payload = $domain->addActivity($id, $data);
0 ignored issues
show
Bug introduced by
The method addActivity() does not seem to exist on object<keeko\core\domain\UserDomain>.

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.

Loading history...
43
		return $this->responder->run($request, $payload);
44
	}
45
}
46