Completed
Push — master ( c9073d...17137d )
by Thomas
17:02
created

ReadActionTraitGenerator::addMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 18
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 18
rs 9.4286
cc 1
eloc 12
nc 1
nop 2
1
<?php
2
namespace keeko\tools\generator\action\base;
3
4
use gossi\codegen\model\PhpTrait;
5
use keeko\core\schema\ActionSchema;
6
use keeko\tools\generator\AbstractActionTraitGenerator;
7
use keeko\tools\utils\NameUtils;
8
9 View Code Duplication
class ReadActionTraitGenerator extends AbstractActionTraitGenerator {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
	
11
	/* (non-PHPdoc)
12
	 * @see \keeko\tools\generator\AbstractTraitGenerator::addMethods()
13
	 */
14
	protected function addMethods(PhpTrait $trait, ActionSchema $action) {
15
		$modelName = $this->modelService->getModelNameByAction($action);
16
		$modelVariableName = NameUtils::toCamelCase($modelName);
17
		$modelObjectName = NameUtils::toStudlyCase($modelName);
18
		$fullModelObjectName = $this->modelService->getFullModelObjectName($action);
19
	
20
		// method: configureParams(OptionsResolver $resolver)
21
		$this->addConfigureParamsMethod($trait, $this->twig->render('read-configureParams.twig'));
22
	
23
		// method: run(Request $request)
24
		$trait->addUseStatement($fullModelObjectName);
25
		$trait->addUseStatement($fullModelObjectName . 'Query');
26
		$trait->addUseStatement('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException');
27
		$trait->setMethod($this->generateRunMethod($this->twig->render('read-run.twig', [
28
			'model' => $modelVariableName,
29
			'class' => $modelObjectName
30
		])));
31
	}
32
	
33
}