@@ -178,14 +178,14 @@ |
||
178 | 178 | // iterate over behaviors to get their respective columns |
179 | 179 | foreach ($table->getBehaviors() as $behavior) { |
180 | 180 | switch ($behavior->getName()) { |
181 | - case 'timestampable': |
|
182 | - $fields[] = $behavior->getParameter('create_column'); |
|
183 | - $fields[] = $behavior->getParameter('update_column'); |
|
184 | - break; |
|
181 | + case 'timestampable': |
|
182 | + $fields[] = $behavior->getParameter('create_column'); |
|
183 | + $fields[] = $behavior->getParameter('update_column'); |
|
184 | + break; |
|
185 | 185 | |
186 | - case 'aggregate_column': |
|
187 | - $fields[] = $behavior->getParameter('name'); |
|
188 | - break; |
|
186 | + case 'aggregate_column': |
|
187 | + $fields[] = $behavior->getParameter('name'); |
|
188 | + break; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use keeko\tools\generator\serializer\base\ModelSerializerTraitGenerator; |
8 | 8 | use keeko\tools\generator\serializer\SkeletonSerializerGenerator; |
9 | 9 | use keeko\tools\helpers\QuestionHelperTrait; |
10 | -use phootwork\file\File; |
|
11 | 10 | use Symfony\Component\Console\Input\InputArgument; |
12 | 11 | use Symfony\Component\Console\Input\InputInterface; |
13 | 12 | use Symfony\Component\Console\Input\InputOption; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | protected function initialize(InputInterface $input, OutputInterface $output) { |
50 | 50 | parent::initialize($input, $output); |
51 | 51 | |
52 | - $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot() . '/serializer'); |
|
52 | + $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot().'/serializer'); |
|
53 | 53 | $this->twig = new \Twig_Environment($loader); |
54 | 54 | } |
55 | 55 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | private function generateModel($modelName) { |
132 | - $this->logger->info('Generate Serializer from Model: ' . $modelName); |
|
132 | + $this->logger->info('Generate Serializer from Model: '.$modelName); |
|
133 | 133 | $model = $this->modelService->getModel($modelName); |
134 | 134 | |
135 | 135 | // generate class |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $this->codegenService->dumpStruct($trait, true); |
144 | 144 | |
145 | 145 | // add serializer + ApiModelInterface on the model |
146 | - $class = new PhpClass(str_replace('\\\\', '\\', $model->getNamespace() . '\\' . $model->getPhpName())); |
|
146 | + $class = new PhpClass(str_replace('\\\\', '\\', $model->getNamespace().'\\'.$model->getPhpName())); |
|
147 | 147 | $file = $this->codegenService->getFile($class); |
148 | 148 | if ($file->exists()) { |
149 | 149 | $class = PhpClass::fromFile($this->codegenService->getFilename($class)); |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | * @param string $name |
174 | 174 | */ |
175 | 175 | private function generateSkeleton($name) { |
176 | - $this->logger->info('Generate Skeleton Serializer: ' . $name); |
|
176 | + $this->logger->info('Generate Skeleton Serializer: '.$name); |
|
177 | 177 | $input = $this->io->getInput(); |
178 | 178 | |
179 | - $className = NamespaceResolver::getNamespace('src/serializer', $this->package) . '\\' . $name; |
|
179 | + $className = NamespaceResolver::getNamespace('src/serializer', $this->package).'\\'.$name; |
|
180 | 180 | |
181 | 181 | if (!Text::create($className)->endsWith('Serializer')) { |
182 | 182 | $className .= 'Serializer'; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | /** |
7 | 7 | * Add default blank methods |
8 | 8 | * |
9 | - * @param string $classname |
|
9 | + * @param string $className |
|
10 | 10 | */ |
11 | 11 | public function generate($className) { |
12 | 12 | $class = $this->generateClass($className); |
@@ -8,6 +8,9 @@ |
||
8 | 8 | |
9 | 9 | protected $serializer; |
10 | 10 | |
11 | + /** |
|
12 | + * @param string $serializer |
|
13 | + */ |
|
11 | 14 | public function setSerializer($serializer) { |
12 | 15 | $this->serializer = $serializer; |
13 | 16 | } |
@@ -27,13 +27,13 @@ |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function getClassName(Table $model) { |
30 | - return str_replace('model', 'serializer', $model->getNamespace()) . |
|
31 | - '\\' . $model->getPhpName() . 'Serializer'; |
|
30 | + return str_replace('model', 'serializer', $model->getNamespace()). |
|
31 | + '\\'.$model->getPhpName().'Serializer'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function ensureDomainTrait(PhpClass $class, Table $model) { |
35 | - $class->addUseStatement(str_replace('model', 'serializer\\base', $model->getNamespace()) . |
|
36 | - '\\' . $model->getPhpName() . 'SerializerTrait'); |
|
37 | - $class->addTrait($model->getPhpName() . 'SerializerTrait'); |
|
35 | + $class->addUseStatement(str_replace('model', 'serializer\\base', $model->getNamespace()). |
|
36 | + '\\'.$model->getPhpName().'SerializerTrait'); |
|
37 | + $class->addTrait($model->getPhpName().'SerializerTrait'); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | private function generateModel($modelName) { |
193 | - $this->logger->info('Generate Action from Model: ' . $modelName); |
|
193 | + $this->logger->info('Generate Action from Model: '.$modelName); |
|
194 | 194 | $input = $this->io->getInput(); |
195 | 195 | $model = $this->modelService->getModel($modelName); |
196 | 196 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | foreach ($types as $type) { |
210 | 210 | $input->setOption('acl', ['admin']); |
211 | 211 | $input->setOption('type', $type); |
212 | - $actionName = $modelName . '-' . $type; |
|
212 | + $actionName = $modelName.'-'.$type; |
|
213 | 213 | |
214 | 214 | if ($model->isReadOnly() && in_array($type, ['create', 'update', 'delete'])) { |
215 | 215 | $this->logger->info(sprintf('Skip generate Action (%s), because Model (%s) is read-only', $actionName, $modelName)); |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | $name = NameUtils::dasherize($modelName); |
253 | 253 | switch ($type) { |
254 | 254 | case 'list': |
255 | - return 'List all ' . NameUtils::pluralize($name); |
|
255 | + return 'List all '.NameUtils::pluralize($name); |
|
256 | 256 | |
257 | 257 | case 'create': |
258 | 258 | case 'read': |
259 | 259 | case 'update': |
260 | 260 | case 'delete': |
261 | - return ucfirst($type) . 's ' . (in_array($name[0], ['a', 'e', 'i', 'o', 'u']) ? 'an' : 'a') . ' ' . $name; |
|
261 | + return ucfirst($type).'s '.(in_array($name[0], ['a', 'e', 'i', 'o', 'u']) ? 'an' : 'a').' '.$name; |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param string $actionName |
291 | 291 | */ |
292 | 292 | private function generateSkeleton($actionName) { |
293 | - $this->logger->info('Generate Skeleton Action: ' . $actionName); |
|
293 | + $this->logger->info('Generate Skeleton Action: '.$actionName); |
|
294 | 294 | $input = $this->io->getInput(); |
295 | 295 | |
296 | 296 | // generate action |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | private function guessClassname($name) { |
351 | 351 | $namespace = NamespaceResolver::getNamespace('src/action', $this->package); |
352 | - return $namespace . '\\' . NameUtils::toStudlyCase($name) . 'Action'; |
|
352 | + return $namespace.'\\'.NameUtils::toStudlyCase($name).'Action'; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -413,10 +413,10 @@ discard block |
||
413 | 413 | foreach (array_keys($generators) as $type) { |
414 | 414 | // generate fqcn |
415 | 415 | $className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type)); |
416 | - $fqcn = $this->packageService->getNamespace() . '\\action\\' . $className; |
|
416 | + $fqcn = $this->packageService->getNamespace().'\\action\\'.$className; |
|
417 | 417 | |
418 | 418 | // generate action |
419 | - $action = new ActionSchema($actionNamePrefix . '-' . $type); |
|
419 | + $action = new ActionSchema($actionNamePrefix.'-'.$type); |
|
420 | 420 | $action->addAcl('admin'); |
421 | 421 | $action->setClass($fqcn); |
422 | 422 | $action->setTitle(str_replace( |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | foreach (array_keys($generators) as $type) { |
455 | 455 | // generate fqcn |
456 | 456 | $className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type)); |
457 | - $fqcn = $this->packageService->getNamespace() . '\\action\\' . $className; |
|
457 | + $fqcn = $this->packageService->getNamespace().'\\action\\'.$className; |
|
458 | 458 | |
459 | 459 | // generate action |
460 | - $action = new ActionSchema($actionNamePrefix . '-' . $type); |
|
460 | + $action = new ActionSchema($actionNamePrefix.'-'.$type); |
|
461 | 461 | $action->addAcl('admin'); |
462 | 462 | $action->setClass($fqcn); |
463 | 463 | $action->setTitle(str_replace( |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | // aks for serializer |
151 | 151 | if ($format == 'json' && $template == 'api') { |
152 | - $guessedSerializer = NameUtils::toStudlyCase($name) . 'Serializer'; |
|
152 | + $guessedSerializer = NameUtils::toStudlyCase($name).'Serializer'; |
|
153 | 153 | $serializerQuestion = new Question('Which format', $guessedSerializer); |
154 | 154 | $serializer = $this->askQuestion($serializerQuestion); |
155 | 155 | $input->setOption('serializer', $serializer); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | // generate responders for crud actions |
192 | 192 | foreach ($types as $type) { |
193 | - $actionName = $modelName . '-' . $type; |
|
193 | + $actionName = $modelName.'-'.$type; |
|
194 | 194 | |
195 | 195 | $this->generateResponder($actionName); |
196 | 196 | } |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | $fk = $relationship['fk']; |
207 | 207 | $foreignName = $fk->getForeignTable()->getOriginCommonName(); |
208 | 208 | foreach ($types[$relationship['type']] as $type) { |
209 | - $this->generateResponder($modelName . '-to-' . $foreignName . '-relationship-' . $type); |
|
209 | + $this->generateResponder($modelName.'-to-'.$foreignName.'-relationship-'.$type); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | 215 | protected function generateResponder($actionName) { |
216 | - $this->logger->info('Generate Responder for: ' . $actionName); |
|
216 | + $this->logger->info('Generate Responder for: '.$actionName); |
|
217 | 217 | $module = $this->packageService->getModule(); |
218 | 218 | |
219 | 219 | if (!$module->hasAction($actionName)) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | if (!$action->hasResponse($format)) { |
236 | 236 | $className = str_replace('action', 'responder', $action->getClass()); |
237 | - $className = preg_replace('/Action$/', ucwords($format) . 'Responder', $className); |
|
237 | + $className = preg_replace('/Action$/', ucwords($format).'Responder', $className); |
|
238 | 238 | $action->setResponse($format, $className); |
239 | 239 | } |
240 | 240 | |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | $foreign->getPhpName() |
302 | 302 | ); |
303 | 303 | |
304 | - $many = $module->hasAction($prefix . '-read') |
|
305 | - && $module->hasAction($prefix . '-update') |
|
306 | - && $module->hasAction($prefix . '-add') |
|
307 | - && $module->hasAction($prefix . '-remove') |
|
304 | + $many = $module->hasAction($prefix.'-read') |
|
305 | + && $module->hasAction($prefix.'-update') |
|
306 | + && $module->hasAction($prefix.'-add') |
|
307 | + && $module->hasAction($prefix.'-remove') |
|
308 | 308 | ; |
309 | - $single = $module->hasAction($prefix . '-read') |
|
310 | - && $module->hasAction($prefix . '-update') |
|
309 | + $single = $module->hasAction($prefix.'-read') |
|
310 | + && $module->hasAction($prefix.'-update') |
|
311 | 311 | && !$many |
312 | 312 | ; |
313 | 313 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | // check fqcn |
337 | 337 | $class = PhpClass::create($serializer); |
338 | 338 | if ($class->getQualifiedName() == $serializer) { |
339 | - $class->setQualifiedName(NamespaceResolver::getNamespace('src/serializer', $this->package) . |
|
340 | - '\\' . $serializer); |
|
339 | + $class->setQualifiedName(NamespaceResolver::getNamespace('src/serializer', $this->package). |
|
340 | + '\\'.$serializer); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | // check serializer exists |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | protected function initialize(InputInterface $input, OutputInterface $output) { |
47 | 47 | parent::initialize($input, $output); |
48 | 48 | |
49 | - $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot() . '/domain'); |
|
49 | + $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot().'/domain'); |
|
50 | 50 | $this->twig = new \Twig_Environment($loader); |
51 | 51 | } |
52 | 52 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | private function generateModel($modelName) { |
132 | - $this->logger->info('Generate Domain from Model: ' . $modelName); |
|
132 | + $this->logger->info('Generate Domain from Model: '.$modelName); |
|
133 | 133 | $model = $this->modelService->getModel($modelName); |
134 | 134 | |
135 | 135 | // generate class |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | private function generateSkeleton($name) { |
149 | - $this->logger->info('Generate Skeleton Domain: ' . $name); |
|
149 | + $this->logger->info('Generate Skeleton Domain: '.$name); |
|
150 | 150 | $input = $this->io->getInput(); |
151 | 151 | |
152 | - $className = NamespaceResolver::getNamespace('src/domain', $this->package) . '\\' . $name; |
|
152 | + $className = NamespaceResolver::getNamespace('src/domain', $this->package).'\\'.$name; |
|
153 | 153 | |
154 | 154 | if (!Text::create($className)->endsWith('Domain')) { |
155 | 155 | $className .= 'Domain'; |