Conditions | 2 |
Paths | 2 |
Total Lines | 25 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | protected function addMethods(PhpClass $class, ActionSchema $action) { |
||
10 | $this->generateGetPayloadMethods($class, $this->twig->render('model/getPayloadMethods-paginate.twig')); |
||
11 | |||
12 | // method: found(Request $request, Found $payload) : JsonResponse |
||
13 | $modelName = $this->modelService->getModelNameByAction($action); |
||
14 | $model = $this->modelService->getModel($modelName); |
||
15 | $fields = $this->getModelFields($model); |
||
16 | foreach ($fields as $field) { |
||
17 | $class->addUseStatement($field->getNamespace() . '\\' . $field->getPhpName()); |
||
18 | } |
||
19 | |||
20 | $includes = $this->codegenService->arrayToCode($this->getRelationshipIncludes($model)); |
||
21 | $found = $this->generatePayloadMethod('found', $this->twig->render('model/paginate.twig', [ |
||
22 | 'class' => $model->getPhpName(), |
||
23 | 'includes' => $includes, |
||
24 | 'fields' => $this->getFieldsCode($fields) |
||
25 | ]), 'Found'); |
||
26 | |||
27 | $class->setMethod($found); |
||
28 | $class->addUseStatement('keeko\\framework\\domain\\payload\\Found'); |
||
29 | $class->addUseStatement('Tobscure\\JsonApi\\Document'); |
||
30 | $class->addUseStatement('Tobscure\\JsonApi\\Collection'); |
||
31 | $class->addUseStatement('Tobscure\\JsonApi\\Parameters'); |
||
32 | $class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName()); |
||
33 | } |
||
34 | |||
35 | } |