Completed
Push — master ( 2fb143...d99a08 )
by Thomas
09:36
created

ModelCreateActionGenerator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addMethods() 0 11 1
1
<?php
2
namespace keeko\tools\generator\action;
3
4
use gossi\codegen\model\PhpClass;
5
use keeko\framework\schema\ActionSchema;
6
7
class ModelCreateActionGenerator extends AbstractModelActionGenerator {
8
	
9
	/* (non-PHPdoc)
10
	 * @see \keeko\tools\generator\AbstractTraitGenerator::addMethods()
11
	 */
12
	protected function addMethods(PhpClass $class, ActionSchema $action) {
13
		$modelName = $this->modelService->getModelNameByAction($action);
14
		$model = $this->modelService->getModel($modelName);
15
16
		// method: run(Request $request)
17
		$class->addUseStatement('phootwork\\json\\Json');
18
		$class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()) . '\\' . $model->getPhpName() . 'Domain');
19
		$class->setMethod($this->generateRunMethod($this->twig->render('create-run.twig', [
20
			'domain' => $model->getPhpName() . 'Domain'
21
		])));
22
	}
23
}