@@ -358,13 +358,13 @@ |
||
| 358 | 358 | $type = $this->getPackageType(); |
| 359 | 359 | |
| 360 | 360 | switch ($type) { |
| 361 | - case 'app': |
|
| 362 | - $this->handleAppClass($class); |
|
| 363 | - break; |
|
| 361 | + case 'app': |
|
| 362 | + $this->handleAppClass($class); |
|
| 363 | + break; |
|
| 364 | 364 | |
| 365 | - case 'module': |
|
| 366 | - $this->handleModuleClass($class); |
|
| 367 | - break; |
|
| 365 | + case 'module': |
|
| 366 | + $this->handleModuleClass($class); |
|
| 367 | + break; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $this->codegenService->dumpStruct($class, true); |
@@ -153,14 +153,14 @@ |
||
| 153 | 153 | // iterate over behaviors to get their respective columns |
| 154 | 154 | foreach ($table->getBehaviors() as $behavior) { |
| 155 | 155 | switch ($behavior->getName()) { |
| 156 | - case 'timestampable': |
|
| 157 | - $fields[] = $behavior->getParameter('create_column'); |
|
| 158 | - $fields[] = $behavior->getParameter('update_column'); |
|
| 159 | - break; |
|
| 160 | - |
|
| 161 | - case 'aggregate_column': |
|
| 162 | - $fields[] = $behavior->getParameter('name'); |
|
| 163 | - break; |
|
| 156 | + case 'timestampable': |
|
| 157 | + $fields[] = $behavior->getParameter('create_column'); |
|
| 158 | + $fields[] = $behavior->getParameter('update_column'); |
|
| 159 | + break; |
|
| 160 | + |
|
| 161 | + case 'aggregate_column': |
|
| 162 | + $fields[] = $behavior->getParameter('name'); |
|
| 163 | + break; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -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(); |
@@ -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(); |
@@ -268,14 +268,14 @@ |
||
| 268 | 268 | private function getActionTitle($modelName, $type) { |
| 269 | 269 | $name = NameUtils::dasherize($modelName); |
| 270 | 270 | switch ($type) { |
| 271 | - case 'list': |
|
| 272 | - return 'List all ' . NameUtils::pluralize($name); |
|
| 271 | + case 'list': |
|
| 272 | + return 'List all ' . NameUtils::pluralize($name); |
|
| 273 | 273 | |
| 274 | - case 'create': |
|
| 275 | - case 'read': |
|
| 276 | - case 'update': |
|
| 277 | - case 'delete': |
|
| 278 | - return ucfirst($type) . 's ' . (in_array($name[0], ['a', 'e', 'i', 'o', 'u']) ? 'an' : 'a') . ' ' . $name; |
|
| 274 | + case 'create': |
|
| 275 | + case 'read': |
|
| 276 | + case 'update': |
|
| 277 | + case 'delete': |
|
| 278 | + return ucfirst($type) . 's ' . (in_array($name[0], ['a', 'e', 'i', 'o', 'u']) ? 'an' : 'a') . ' ' . $name; |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
@@ -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 | */ |
@@ -206,20 +206,20 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | // find path branch |
| 208 | 208 | switch ($type) { |
| 209 | - case 'list': |
|
| 210 | - case 'create': |
|
| 211 | - $endpoint = '/' . $modelPluralName; |
|
| 212 | - break; |
|
| 209 | + case 'list': |
|
| 210 | + case 'create': |
|
| 211 | + $endpoint = '/' . $modelPluralName; |
|
| 212 | + break; |
|
| 213 | 213 | |
| 214 | - case 'read': |
|
| 215 | - case 'update': |
|
| 216 | - case 'delete': |
|
| 217 | - $endpoint = '/' . $modelPluralName . '/{id}'; |
|
| 218 | - break; |
|
| 214 | + case 'read': |
|
| 215 | + case 'update': |
|
| 216 | + case 'delete': |
|
| 217 | + $endpoint = '/' . $modelPluralName . '/{id}'; |
|
| 218 | + break; |
|
| 219 | 219 | |
| 220 | - default: |
|
| 221 | - throw new \RuntimeException(sprintf('type (%s) not found, can\'t continue.', $type)); |
|
| 222 | - break; |
|
| 220 | + default: |
|
| 221 | + throw new \RuntimeException(sprintf('type (%s) not found, can\'t continue.', $type)); |
|
| 222 | + break; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | $path = $paths->get($endpoint); |
@@ -234,45 +234,45 @@ discard block |
||
| 234 | 234 | $responses = $operation->getResponses(); |
| 235 | 235 | |
| 236 | 236 | switch ($type) { |
| 237 | - case 'list': |
|
| 238 | - $ok = $responses->get('200'); |
|
| 239 | - $ok->setDescription(sprintf('Array of %s', $modelPluralName)); |
|
| 240 | - $ok->getSchema()->setRef('#/definitions/' . 'Paged' . NameUtils::pluralize($modelObjectName)); |
|
| 241 | - break; |
|
| 237 | + case 'list': |
|
| 238 | + $ok = $responses->get('200'); |
|
| 239 | + $ok->setDescription(sprintf('Array of %s', $modelPluralName)); |
|
| 240 | + $ok->getSchema()->setRef('#/definitions/' . 'Paged' . NameUtils::pluralize($modelObjectName)); |
|
| 241 | + break; |
|
| 242 | 242 | |
| 243 | - case 'create': |
|
| 244 | - // params |
|
| 245 | - $body = $params->getByName('body'); |
|
| 246 | - $body->setName('body'); |
|
| 247 | - $body->setIn('body'); |
|
| 248 | - $body->setDescription(sprintf('The new %s', $modelName)); |
|
| 249 | - $body->setRequired(true); |
|
| 250 | - $body->getSchema()->setRef('#/definitions/Writable' . $modelObjectName); |
|
| 243 | + case 'create': |
|
| 244 | + // params |
|
| 245 | + $body = $params->getByName('body'); |
|
| 246 | + $body->setName('body'); |
|
| 247 | + $body->setIn('body'); |
|
| 248 | + $body->setDescription(sprintf('The new %s', $modelName)); |
|
| 249 | + $body->setRequired(true); |
|
| 250 | + $body->getSchema()->setRef('#/definitions/Writable' . $modelObjectName); |
|
| 251 | 251 | |
| 252 | - // response |
|
| 253 | - $ok = $responses->get('201'); |
|
| 254 | - $ok->setDescription(sprintf('%s created', $modelName)); |
|
| 255 | - break; |
|
| 252 | + // response |
|
| 253 | + $ok = $responses->get('201'); |
|
| 254 | + $ok->setDescription(sprintf('%s created', $modelName)); |
|
| 255 | + break; |
|
| 256 | 256 | |
| 257 | - case 'read': |
|
| 258 | - // response |
|
| 259 | - $ok = $responses->get('200'); |
|
| 260 | - $ok->setDescription(sprintf('gets the %s', $modelName)); |
|
| 261 | - $ok->getSchema()->setRef('#/definitions/' . $modelObjectName); |
|
| 262 | - break; |
|
| 257 | + case 'read': |
|
| 258 | + // response |
|
| 259 | + $ok = $responses->get('200'); |
|
| 260 | + $ok->setDescription(sprintf('gets the %s', $modelName)); |
|
| 261 | + $ok->getSchema()->setRef('#/definitions/' . $modelObjectName); |
|
| 262 | + break; |
|
| 263 | 263 | |
| 264 | - case 'update': |
|
| 265 | - // response |
|
| 266 | - $ok = $responses->get('200'); |
|
| 267 | - $ok->setDescription(sprintf('%s updated', $modelName)); |
|
| 268 | - $ok->getSchema()->setRef('#/definitions/' . $modelObjectName); |
|
| 269 | - break; |
|
| 264 | + case 'update': |
|
| 265 | + // response |
|
| 266 | + $ok = $responses->get('200'); |
|
| 267 | + $ok->setDescription(sprintf('%s updated', $modelName)); |
|
| 268 | + $ok->getSchema()->setRef('#/definitions/' . $modelObjectName); |
|
| 269 | + break; |
|
| 270 | 270 | |
| 271 | - case 'delete': |
|
| 272 | - // response |
|
| 273 | - $ok = $responses->get('204'); |
|
| 274 | - $ok->setDescription(sprintf('%s deleted', $modelName)); |
|
| 275 | - break; |
|
| 271 | + case 'delete': |
|
| 272 | + // response |
|
| 273 | + $ok = $responses->get('204'); |
|
| 274 | + $ok->setDescription(sprintf('%s deleted', $modelName)); |
|
| 275 | + break; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | if ($type == 'read' || $type == 'update' || $type == 'delete') { |
@@ -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()) |
@@ -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') |
@@ -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; |
@@ -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; |