@@ -281,7 +281,6 @@ discard block |
||
| 281 | 281 | /** |
| 282 | 282 | * Generates an action. |
| 283 | 283 | * |
| 284 | - * @param string $actionName |
|
| 285 | 284 | * @param ActionSchema $action the action node from composer.json |
| 286 | 285 | */ |
| 287 | 286 | private function generateNamed($actionName) { |
@@ -295,7 +294,7 @@ discard block |
||
| 295 | 294 | /** |
| 296 | 295 | * Generates the action for the package |
| 297 | 296 | * |
| 298 | - * @param unknown $actionName |
|
| 297 | + * @param string $actionName |
|
| 299 | 298 | * @throws \RuntimeException |
| 300 | 299 | * @return ActionSchema |
| 301 | 300 | */ |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | private function generateModel($modelName) { |
| 186 | - $this->logger->info('Generate Action from Model: ' . $modelName); |
|
| 186 | + $this->logger->info('Generate Action from Model: '.$modelName); |
|
| 187 | 187 | $input = $this->io->getInput(); |
| 188 | 188 | $model = $this->modelService->getModel($modelName); |
| 189 | 189 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | foreach ($types as $type) { |
| 203 | 203 | $input->setOption('acl', ['admin']); |
| 204 | 204 | $input->setOption('type', $type); |
| 205 | - $actionName = $modelName . '-' . $type; |
|
| 205 | + $actionName = $modelName.'-'.$type; |
|
| 206 | 206 | |
| 207 | 207 | if ($model->isReadOnly() && in_array($type, ['create', 'update', 'delete'])) { |
| 208 | 208 | $this->logger->info(sprintf('Skip generate Action (%s), because Model (%s) is read-only', $actionName, $modelName)); |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | $name = NameUtils::dasherize($modelName); |
| 247 | 247 | switch ($type) { |
| 248 | 248 | case 'list': |
| 249 | - return 'List all ' . NameUtils::pluralize($name); |
|
| 249 | + return 'List all '.NameUtils::pluralize($name); |
|
| 250 | 250 | |
| 251 | 251 | case 'create': |
| 252 | 252 | case 'read': |
| 253 | 253 | case 'update': |
| 254 | 254 | case 'delete': |
| 255 | - return ucfirst($type) . 's ' . (in_array($name[0], ['a', 'e', 'i', 'o', 'u']) ? 'an' : 'a') . ' ' . $name; |
|
| 255 | + return ucfirst($type).'s '.(in_array($name[0], ['a', 'e', 'i', 'o', 'u']) ? 'an' : 'a').' '.$name; |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param ActionSchema $action the action node from composer.json |
| 286 | 286 | */ |
| 287 | 287 | private function generateNamed($actionName) { |
| 288 | - $this->logger->info('Generate Action: ' . $actionName); |
|
| 288 | + $this->logger->info('Generate Action: '.$actionName); |
|
| 289 | 289 | $action = $this->generateAction($actionName); |
| 290 | 290 | |
| 291 | 291 | // generate code |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | private function guessClassname($name) { |
| 341 | 341 | $namespace = NamespaceResolver::getNamespace('src/action', $this->package); |
| 342 | - return $namespace . '\\' . NameUtils::toStudlyCase($name) . 'Action'; |
|
| 342 | + return $namespace.'\\'.NameUtils::toStudlyCase($name).'Action'; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -398,14 +398,14 @@ discard block |
||
| 398 | 398 | // class |
| 399 | 399 | $class = new PhpClass($action->getClass()); |
| 400 | 400 | $filename = $this->codegenService->getFilename($class); |
| 401 | - $traitNs = $class->getNamespace() . '\\base'; |
|
| 402 | - $traitName = $class->getName() . 'Trait'; |
|
| 401 | + $traitNs = $class->getNamespace().'\\base'; |
|
| 402 | + $traitName = $class->getName().'Trait'; |
|
| 403 | 403 | $overwrite = false; |
| 404 | 404 | |
| 405 | 405 | // load from file, when class exists |
| 406 | 406 | if (file_exists($filename)) { |
| 407 | 407 | // load trait |
| 408 | - $trait = new PhpTrait($traitNs . '\\' . $traitName); |
|
| 408 | + $trait = new PhpTrait($traitNs.'\\'.$traitName); |
|
| 409 | 409 | $traitFile = new File($this->codegenService->getFilename($trait)); |
| 410 | 410 | |
| 411 | 411 | if ($traitFile->exists()) { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | if ($modelName !== null) { |
| 431 | 431 | $type = $this->packageService->getActionType($action->getName(), $modelName); |
| 432 | 432 | $generator = GeneratorFactory::createActionTraitGenerator($type, $this->service); |
| 433 | - $trait = $generator->generate($traitNs . '\\' . $traitName, $action); |
|
| 433 | + $trait = $generator->generate($traitNs.'\\'.$traitName, $action); |
|
| 434 | 434 | |
| 435 | 435 | $this->codegenService->addAuthors($trait, $this->package); |
| 436 | 436 | $this->codegenService->dumpStruct($trait, true); |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | foreach (array_keys($generators) as $type) { |
| 473 | 473 | // generate fqcn |
| 474 | 474 | $className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type)); |
| 475 | - $fqcn = $this->packageService->getNamespace() . '\\action\\' . $className; |
|
| 475 | + $fqcn = $this->packageService->getNamespace().'\\action\\'.$className; |
|
| 476 | 476 | |
| 477 | 477 | // generate action |
| 478 | - $action = new ActionSchema($actionNamePrefix . '-' . $type); |
|
| 478 | + $action = new ActionSchema($actionNamePrefix.'-'.$type); |
|
| 479 | 479 | $action->addAcl('admin'); |
| 480 | 480 | $action->setClass($fqcn); |
| 481 | 481 | $action->setTitle(str_replace( |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | foreach (array_keys($generators) as $type) { |
| 514 | 514 | // generate fqcn |
| 515 | 515 | $className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type)); |
| 516 | - $fqcn = $this->packageService->getNamespace() . '\\action\\' . $className; |
|
| 516 | + $fqcn = $this->packageService->getNamespace().'\\action\\'.$className; |
|
| 517 | 517 | |
| 518 | 518 | // generate action |
| 519 | - $action = new ActionSchema($actionNamePrefix . '-' . $type); |
|
| 519 | + $action = new ActionSchema($actionNamePrefix.'-'.$type); |
|
| 520 | 520 | $action->addAcl('admin'); |
| 521 | 521 | $action->setClass($fqcn); |
| 522 | 522 | $action->setTitle(str_replace( |
@@ -11,9 +11,8 @@ |
||
| 11 | 11 | /** |
| 12 | 12 | * Generates an action trait with the given name as classname |
| 13 | 13 | * |
| 14 | - * @param string $name |
|
| 15 | 14 | * @param ActionSchema $action |
| 16 | - * @return PhpTrait |
|
| 15 | + * @return PhpClass |
|
| 17 | 16 | */ |
| 18 | 17 | public function generate(ActionSchema $action) { |
| 19 | 18 | $class = PhpClass::create($action->getClass()) |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function generate(ActionSchema $action) { |
| 19 | 19 | $class = PhpClass::create($action->getClass()) |
| 20 | - ->setDescription('Action Class for ' . $action->getName()) |
|
| 20 | + ->setDescription('Action Class for '.$action->getName()) |
|
| 21 | 21 | ->setLongDescription('This code is automatically created. Modifications will probably be overwritten.'); |
| 22 | 22 | |
| 23 | 23 | $this->ensureBasicSetup($class); |
@@ -32,6 +32,10 @@ |
||
| 32 | 32 | ); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | + /** |
|
| 36 | + * @param string $name |
|
| 37 | + * @param string $body |
|
| 38 | + */ |
|
| 35 | 39 | protected function generatePayloadMethod($name, $body) { |
| 36 | 40 | return PhpMethod::create($name) |
| 37 | 41 | ->addParameter(PhpParameter::create('request') |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | if ($rel['type'] == 'many') { |
| 74 | 74 | $typeName = NameUtils::pluralize($typeName); |
| 75 | 75 | } |
| 76 | - $includes[] = (!empty($root) ? $root . '.' : '') . $typeName; |
|
| 76 | + $includes[] = (!empty($root) ? $root.'.' : '').$typeName; |
|
| 77 | 77 | $includes = array_merge($includes, $this->getRelationshipIncludes($foreignModel, $typeName, $processed)); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if ($rel['type'] == 'many') { |
| 99 | 99 | $typeName = NameUtils::pluralize($typeName); |
| 100 | 100 | } |
| 101 | - $name = (!empty($root) ? $root . '.' : '') . $typeName; |
|
| 101 | + $name = (!empty($root) ? $root.'.' : '').$typeName; |
|
| 102 | 102 | |
| 103 | 103 | $fields[$name] = $foreignModel; |
| 104 | 104 | $fields = array_merge($fields, $this->getModelFields($foreignModel, $name, $processed)); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | protected function initialize(InputInterface $input, OutputInterface $output) { |
| 55 | 55 | parent::initialize($input, $output); |
| 56 | 56 | |
| 57 | - $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot() . '/domain'); |
|
| 57 | + $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot().'/domain'); |
|
| 58 | 58 | $this->twig = new \Twig_Environment($loader); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | private function generateModel($modelName) { |
| 153 | - $this->logger->info('Generate Domain from Model: ' . $modelName); |
|
| 153 | + $this->logger->info('Generate Domain from Model: '.$modelName); |
|
| 154 | 154 | $model = $this->modelService->getModel($modelName); |
| 155 | 155 | |
| 156 | 156 | // generate class |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | protected function generateResponse($actionName) { |
| 143 | - $this->logger->info('Generate Response: ' . $actionName); |
|
| 143 | + $this->logger->info('Generate Response: '.$actionName); |
|
| 144 | 144 | $module = $this->packageService->getModule(); |
| 145 | 145 | |
| 146 | 146 | if (!$module->hasAction($actionName)) { |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $modelName = $this->modelService->getModelNameByAction($action); |
| 161 | 161 | |
| 162 | 162 | if (!$action->hasResponse($format)) { |
| 163 | - $action->setResponse($format, str_replace(['Action', 'action'], [ucwords($format) . 'Responder', 'responder'], $action->getClass())); |
|
| 163 | + $action->setResponse($format, str_replace(['Action', 'action'], [ucwords($format).'Responder', 'responder'], $action->getClass())); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // find generator |
@@ -228,13 +228,13 @@ discard block |
||
| 228 | 228 | $foreign->getPhpName() |
| 229 | 229 | ); |
| 230 | 230 | |
| 231 | - $many = $module->hasAction($prefix . '-read') |
|
| 232 | - && $module->hasAction($prefix . '-update') |
|
| 233 | - && $module->hasAction($prefix . '-add') |
|
| 234 | - && $module->hasAction($prefix . '-remove') |
|
| 231 | + $many = $module->hasAction($prefix.'-read') |
|
| 232 | + && $module->hasAction($prefix.'-update') |
|
| 233 | + && $module->hasAction($prefix.'-add') |
|
| 234 | + && $module->hasAction($prefix.'-remove') |
|
| 235 | 235 | ; |
| 236 | - $single = $module->hasAction($prefix . '-read') |
|
| 237 | - && $module->hasAction($prefix . '-update') |
|
| 236 | + $single = $module->hasAction($prefix.'-read') |
|
| 237 | + && $module->hasAction($prefix.'-update') |
|
| 238 | 238 | && !$many |
| 239 | 239 | ; |
| 240 | 240 | |
@@ -17,9 +17,9 @@ |
||
| 17 | 17 | $this->addConfigureParamsMethod($class, $this->twig->render('read-configureParams.twig')); |
| 18 | 18 | |
| 19 | 19 | // method: run(Request $request) |
| 20 | - $class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()) . '\\' . $model->getPhpName() . 'Domain'); |
|
| 20 | + $class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()).'\\'.$model->getPhpName().'Domain'); |
|
| 21 | 21 | $class->setMethod($this->generateRunMethod($this->twig->render('read-run.twig', [ |
| 22 | - 'domain' => $model->getPhpName() . 'Domain' |
|
| 22 | + 'domain' => $model->getPhpName().'Domain' |
|
| 23 | 23 | ]))); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -15,9 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | // method: run(Request $request) |
| 17 | 17 | $class->addUseStatement('Tobscure\\JsonApi\\Parameters'); |
| 18 | - $class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()) . '\\' . $model->getPhpName() . 'Domain'); |
|
| 18 | + $class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()).'\\'.$model->getPhpName().'Domain'); |
|
| 19 | 19 | $class->setMethod($this->generateRunMethod($this->twig->render('list-run.twig', [ |
| 20 | - 'domain' => $model->getPhpName() . 'Domain' |
|
| 20 | + 'domain' => $model->getPhpName().'Domain' |
|
| 21 | 21 | ]))); |
| 22 | 22 | |
| 23 | 23 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | $this->addConfigureParamsMethod($class, $this->twig->render('relationship-configureParams.twig')); |
| 21 | 21 | |
| 22 | 22 | // method: run(Request $request) : Response |
| 23 | - $class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName() . 'Query'); |
|
| 23 | + $class->addUseStatement($model->getNamespace().'\\'.$model->getPhpName().'Query'); |
|
| 24 | 24 | $class->setMethod($this->generateRunMethod($this->twig->render('to-one-read-run.twig', [ |
| 25 | 25 | 'model' => $model->getCamelCaseName(), |
| 26 | 26 | 'class' => $model->getPhpName() |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | $class->addUseStatement('keeko\\framework\\exceptions\\ValidationException'); |
| 24 | 24 | $class->addUseStatement('Tobscure\\JsonApi\\Exception\\InvalidParameterException'); |
| 25 | 25 | $class->addUseStatement('phootwork\\json\\Json'); |
| 26 | - $class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName() . 'Query'); |
|
| 26 | + $class->addUseStatement($model->getNamespace().'\\'.$model->getPhpName().'Query'); |
|
| 27 | 27 | $class->setMethod($this->generateRunMethod($this->twig->render('to-one-update-run.twig', [ |
| 28 | 28 | 'model' => $model->getCamelCaseName(), |
| 29 | 29 | 'class' => $model->getPhpName(), |