@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $this->setDispatcher($dispatcher); |
| 29 | 29 | $this->keekoDispatcher = $dispatcher; |
| 30 | 30 | |
| 31 | - $dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) { |
|
| 31 | + $dispatcher->addListener(ConsoleEvents::TERMINATE, function(ConsoleTerminateEvent $event) { |
|
| 32 | 32 | $command = $event->getCommand(); |
| 33 | 33 | $this->finishedCommands[] = $command->getName(); |
| 34 | 34 | }); |
@@ -24,8 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | protected function getQuestion($question, $default = null, $sep = ':') { |
| 26 | 26 | return !empty($default) ? |
| 27 | - sprintf('<info>%s</info> [<comment>%s</comment>]%s ', $question, $default, $sep) : |
|
| 28 | - sprintf('<info>%s</info>%s ', $question, $sep); |
|
| 27 | + sprintf('<info>%s</info> [<comment>%s</comment>]%s ', $question, $default, $sep) : sprintf('<info>%s</info>%s ', $question, $sep); |
|
| 29 | 28 | } |
| 30 | 29 | |
| 31 | 30 | /** |
@@ -91,6 +91,9 @@ |
||
| 91 | 91 | ; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | + /** |
|
| 95 | + * @param string $name |
|
| 96 | + */ |
|
| 94 | 97 | protected function runCommand($name, InputInterface $input, OutputInterface $output) { |
| 95 | 98 | // return whether command has already executed |
| 96 | 99 | $app = $this->getApplication(); |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | * Adds authors to the docblock of the given struct |
| 63 | 63 | * |
| 64 | 64 | * @param AbstractPhpStruct $struct |
| 65 | - * @param array $package |
|
| 65 | + * @param PackageSchema $package |
|
| 66 | 66 | */ |
| 67 | 67 | public function addAuthors(AbstractPhpStruct $struct, PackageSchema $package) { |
| 68 | 68 | $docblock = $struct->getDocblock(); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function getCodegenFile() { |
| 19 | 19 | $basepath = dirname($this->project->getComposerFileName()); |
| 20 | - return $basepath . '/codegen.json'; |
|
| 20 | + return $basepath.'/codegen.json'; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $jsonFile = $this->project->getComposerFileName(); |
| 230 | 230 | $path = new Path(dirname($jsonFile)); |
| 231 | 231 | $path = $path->append($relativeSourcePath); |
| 232 | - $path = $path->append($struct->getName() . '.php'); |
|
| 232 | + $path = $path->append($struct->getName().'.php'); |
|
| 233 | 233 | return $path->toString(); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -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)); |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | /** @var Table */ |
| 15 | 15 | private $foreign; |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param \keeko\tools\services\CommandService $service |
|
| 19 | + */ |
|
| 17 | 20 | public function __construct($service, Table $model, Table $foreign) { |
| 18 | 21 | parent::__construct($service); |
| 19 | 22 | $this->model = $model; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | protected function addMethods(PhpClass $class, ActionSchema $action) { |
| 23 | 23 | // method: run(Request $request, $data = null) |
| 24 | - $class->addUseStatement($this->model->getNamespace() . '\\' . $this->model->getPhpName()); |
|
| 24 | + $class->addUseStatement($this->model->getNamespace().'\\'.$this->model->getPhpName()); |
|
| 25 | 25 | $class->setMethod($this->generateRunMethod($this->twig->render('dump-to-one-relationship.twig', [ |
| 26 | 26 | 'class' => $this->model->getPhpName(), |
| 27 | 27 | 'related' => $this->foreign->getCamelCaseName() |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | /** @var Table */ |
| 15 | 15 | private $foreign; |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param \keeko\tools\services\CommandService $service |
|
| 19 | + */ |
|
| 17 | 20 | public function __construct($service, Table $model, Table $foreign) { |
| 18 | 21 | parent::__construct($service); |
| 19 | 22 | $this->model = $model; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | protected function addMethods(PhpClass $class, ActionSchema $action) { |
| 23 | 23 | // method: run(Request $request, $data = null) |
| 24 | - $class->addUseStatement($this->model->getNamespace() . '\\' . $this->model->getPhpName()); |
|
| 24 | + $class->addUseStatement($this->model->getNamespace().'\\'.$this->model->getPhpName()); |
|
| 25 | 25 | $class->setMethod($this->generateRunMethod($this->twig->render('dump-to-one-relationship.twig', [ |
| 26 | 26 | 'class' => $this->model->getPhpName(), |
| 27 | 27 | 'related' => $this->foreign->getCamelCaseName() |