@@ -27,7 +27,7 @@ |
||
27 | 27 | public function parse($value, $sub) |
28 | 28 | { |
29 | 29 | if (substr($value, 0, 2) == '//') { |
30 | - $value = StringHelper::replaceFirst('//', Url::base(true) . '/', $value); |
|
30 | + $value = StringHelper::replaceFirst('//', Url::base(true).'/', $value); |
|
31 | 31 | $external = false; |
32 | 32 | } else { |
33 | 33 | $external = true; |
@@ -70,14 +70,14 @@ |
||
70 | 70 | */ |
71 | 71 | public function run() |
72 | 72 | { |
73 | - $class = 'lazy-image ' . $this->extraClass; |
|
73 | + $class = 'lazy-image '.$this->extraClass; |
|
74 | 74 | |
75 | 75 | if ($this->attributesOnly) { |
76 | 76 | return "class=\"{$class}\" data-src=\"$this->src\" data-width=\"$this->width\" data-height=\"$this->height\" data-as-background=\"1\""; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $tag = Html::tag('img', '', ['class' => $class, 'data-src' => $this->src, 'data-width' => $this->width, 'data-height' => $this->height]); |
80 | - $tag.= '<noscript><img class="'.$class.'" src="'.$this->src.'" /></noscript>'; |
|
80 | + $tag .= '<noscript><img class="'.$class.'" src="'.$this->src.'" /></noscript>'; |
|
81 | 81 | return $tag; |
82 | 82 | } |
83 | 83 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | foreach ($array as $k => $v) { |
51 | 51 | if (is_numeric($v)) { |
52 | 52 | if (is_float($v)) { |
53 | - $return[$k] = (float)$v; |
|
53 | + $return[$k] = (float) $v; |
|
54 | 54 | } else { |
55 | - $return[$k] = (int)$v; |
|
55 | + $return[$k] = (int) $v; |
|
56 | 56 | } |
57 | 57 | } elseif (is_array($v)) { |
58 | 58 | $return[$k] = self::typeCast($v); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public static function search($array, $searchText, $sensitive = false) |
93 | 93 | { |
94 | 94 | $function = ($sensitive) ? 'strpos' : 'stripos'; |
95 | - return array_filter($array, function ($item) use ($searchText, $function) { |
|
95 | + return array_filter($array, function($item) use ($searchText, $function) { |
|
96 | 96 | $response = false; |
97 | 97 | foreach ($item as $key => $value) { |
98 | 98 | if ($response) { |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | } |
75 | 75 | $rules = []; |
76 | 76 | foreach ($types as $type => $columns) { |
77 | - $rules[] = "[['" . implode("', '", $columns) . "'], '$type']"; |
|
77 | + $rules[] = "[['".implode("', '", $columns)."'], '$type']"; |
|
78 | 78 | } |
79 | 79 | foreach ($lengths as $length => $columns) { |
80 | - $rules[] = "[['" . implode("', '", $columns) . "'], 'string', 'max' => $length]"; |
|
80 | + $rules[] = "[['".implode("', '", $columns)."'], 'string', 'max' => $length]"; |
|
81 | 81 | } |
82 | 82 | $db = $this->getDbConnection(); |
83 | 83 | // Unique indexes rules |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | if (!$this->isColumnAutoIncremental($table, $uniqueColumns)) { |
89 | 89 | $attributesCount = count($uniqueColumns); |
90 | 90 | if ($attributesCount === 1) { |
91 | - $rules[] = "[['" . $uniqueColumns[0] . "'], 'unique']"; |
|
91 | + $rules[] = "[['".$uniqueColumns[0]."'], 'unique']"; |
|
92 | 92 | } elseif ($attributesCount > 1) { |
93 | 93 | $labels = array_intersect_key($this->generateLabels($table), array_flip($uniqueColumns)); |
94 | 94 | $lastLabel = array_pop($labels); |
95 | 95 | $columnsList = implode("', '", $uniqueColumns); |
96 | - $rules[] = "[['$columnsList'], 'unique', 'targetAttribute' => ['$columnsList'], 'message' => 'The combination of " . implode(', ', $labels) . " and $lastLabel has already been taken.']"; |
|
96 | + $rules[] = "[['$columnsList'], 'unique', 'targetAttribute' => ['$columnsList'], 'message' => 'The combination of ".implode(', ', $labels)." and $lastLabel has already been taken.']"; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $fullTableName = $tableName; |
137 | 137 | if (($pos = strrpos($tableName, '.')) !== false) { |
138 | 138 | if (($useSchemaName === null && $this->useSchemaName) || $useSchemaName) { |
139 | - $schemaName = substr($tableName, 0, $pos) . '_'; |
|
139 | + $schemaName = substr($tableName, 0, $pos).'_'; |
|
140 | 140 | } |
141 | 141 | $tableName = substr($tableName, $pos + 1); |
142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | if (($pos = strrpos($pattern, '.')) !== false) { |
150 | 150 | $pattern = substr($pattern, $pos + 1); |
151 | 151 | } |
152 | - $patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/'; |
|
152 | + $patterns[] = '/^'.str_replace('*', '(\w+)', $pattern).'$/'; |
|
153 | 153 | } |
154 | 154 | $className = $tableName; |
155 | 155 | foreach ($patterns as $pattern) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } else { |
194 | 194 | $label = Inflector::camel2words($column->name); |
195 | 195 | if (!empty($label) && substr_compare($label, ' id', -3, 3, true) === 0) { |
196 | - $label = substr($label, 0, -3) . ' ID'; |
|
196 | + $label = substr($label, 0, -3).' ID'; |
|
197 | 197 | } |
198 | 198 | $labels[$column->name] = $label; |
199 | 199 | } |
@@ -88,8 +88,8 @@ |
||
88 | 88 | { |
89 | 89 | return [ |
90 | 90 | <?php foreach ($extras as $extra):?> |
91 | - <?= $extra;?> |
|
92 | -<?php endforeach;?> |
|
91 | + <?= $extra; ?> |
|
92 | +<?php endforeach; ?> |
|
93 | 93 | |
94 | 94 | ]; |
95 | 95 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function getModelNamespace() |
61 | 61 | { |
62 | - return $this->getNamespace() . '\\models\\' . $this->getModelNameCamlized(); |
|
62 | + return $this->getNamespace().'\\models\\'.$this->getModelNameCamlized(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function getApiEndpointSuggestion() |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $sqlTable = $this->prompt('Database Table name for the Model:', ['required' => true, 'default' => $this->getDatabaseNameSuggestion()]); |
234 | 234 | if ($sqlTable == '?') { |
235 | 235 | foreach ($this->getSqlTablesArray() as $table) { |
236 | - $this->outputInfo("- " . $table); |
|
236 | + $this->outputInfo("- ".$table); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | if (isset($this->getSqlTablesArray()[$sqlTable])) { |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | // api content |
257 | 257 | |
258 | 258 | $files['api'] = [ |
259 | - 'path' => $this->getBasePath() . DIRECTORY_SEPARATOR . 'apis', |
|
260 | - 'fileName' => $this->getModelNameCamlized() . 'Controller.php', |
|
261 | - 'content' => $this->generateApiContent($this->getNamespace() . '\\apis', $this->getModelNameCamlized() . 'Controller', $this->getModelNamespace()), |
|
259 | + 'path' => $this->getBasePath().DIRECTORY_SEPARATOR.'apis', |
|
260 | + 'fileName' => $this->getModelNameCamlized().'Controller.php', |
|
261 | + 'content' => $this->generateApiContent($this->getNamespace().'\\apis', $this->getModelNameCamlized().'Controller', $this->getModelNamespace()), |
|
262 | 262 | ]; |
263 | 263 | |
264 | 264 | // controller |
265 | 265 | |
266 | 266 | $files['controller'] = [ |
267 | - 'path' => $this->getBasePath() . DIRECTORY_SEPARATOR . 'controllers', |
|
268 | - 'fileName' => $this->getModelNameCamlized() . 'Controller.php', |
|
269 | - 'content' => $this->generateControllerContent($this->getNamespace() . '\\controllers', $this->getModelNameCamlized() . 'Controller', $this->getModelNamespace()), |
|
267 | + 'path' => $this->getBasePath().DIRECTORY_SEPARATOR.'controllers', |
|
268 | + 'fileName' => $this->getModelNameCamlized().'Controller.php', |
|
269 | + 'content' => $this->generateControllerContent($this->getNamespace().'\\controllers', $this->getModelNameCamlized().'Controller', $this->getModelNamespace()), |
|
270 | 270 | ]; |
271 | 271 | |
272 | 272 | // model |
273 | 273 | |
274 | 274 | $files['model'] = [ |
275 | - 'path' => $this->getBasePath() . DIRECTORY_SEPARATOR . 'models', |
|
276 | - 'fileName' => $this->getModelNameCamlized() . '.php', |
|
275 | + 'path' => $this->getBasePath().DIRECTORY_SEPARATOR.'models', |
|
276 | + 'fileName' => $this->getModelNameCamlized().'.php', |
|
277 | 277 | 'content' => $this->generateModelContent( |
278 | - $this->getNamespace() . '\\models', |
|
278 | + $this->getNamespace().'\\models', |
|
279 | 279 | $this->getModelNameCamlized(), |
280 | 280 | $this->apiEndpoint, |
281 | 281 | $this->getDbTableShema() |
@@ -284,20 +284,20 @@ discard block |
||
284 | 284 | |
285 | 285 | foreach ($files as $file) { |
286 | 286 | FileHelper::createDirectory($file['path']); |
287 | - if (file_exists($file['path'] . DIRECTORY_SEPARATOR . $file['fileName'])) { |
|
287 | + if (file_exists($file['path'].DIRECTORY_SEPARATOR.$file['fileName'])) { |
|
288 | 288 | if (!$this->confirm("The File '{$file['fileName']}' already exists, do you want to override the existing file?")) { |
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - if (FileHelper::writeFile($file['path'] . DIRECTORY_SEPARATOR . $file['fileName'], $file['content'])) { |
|
293 | + if (FileHelper::writeFile($file['path'].DIRECTORY_SEPARATOR.$file['fileName'], $file['content'])) { |
|
294 | 294 | $this->outputSuccess("Wrote file '{$file['fileName']}'."); |
295 | 295 | } else { |
296 | 296 | $this->outputError("Error while writing file '{$file['fileName']}'."); |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - return $this->outputSuccess($this->generateBuildSummery($this->apiEndpoint, $this->getNamespace() . '\\apis\\' . $this->getModelNameCamlized() . 'Controller', $this->getModelNameCamlized(), $this->getSummaryControllerRoute())); |
|
300 | + return $this->outputSuccess($this->generateBuildSummery($this->apiEndpoint, $this->getNamespace().'\\apis\\'.$this->getModelNameCamlized().'Controller', $this->getModelNameCamlized(), $this->getSummaryControllerRoute())); |
|
301 | 301 | /* |
302 | 302 | // $yiiModule = Yii::$app->getModule($module); |
303 | 303 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | /** |
46 | 46 | * Get the $moduleName without admin suffix (if any). |
47 | 47 | * |
48 | - * @return mixed Return the module name without admin suffix. |
|
48 | + * @return string Return the module name without admin suffix. |
|
49 | 49 | */ |
50 | 50 | public function getModuleNameWithoutAdminSuffix() |
51 | 51 | { |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use yii\helpers\Console; |
7 | 7 | use yii\helpers\Inflector; |
8 | 8 | use yii\db\TableSchema; |
9 | -use luya\Boot; |
|
10 | 9 | use luya\helpers\FileHelper; |
11 | 10 | |
12 | 11 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function generateApiContent($fileNamespace, $className, $modelClass) |
172 | 172 | { |
173 | - $alias = Inflector::humanize(Inflector::camel2words($className)); |
|
173 | + $alias = Inflector::humanize(Inflector::camel2words($className)); |
|
174 | 174 | return $this->view->render('@luya/console/commands/views/crud/create_api.php', [ |
175 | 175 | 'namespace' => $fileNamespace, |
176 | 176 | 'className' => $className, |
177 | 177 | 'modelClass' => $modelClass, |
178 | 178 | 'luyaVersion' => $this->getGeneratorText('crud/create'), |
179 | - 'alias' => $alias, |
|
179 | + 'alias' => $alias, |
|
180 | 180 | ]); |
181 | 181 | } |
182 | 182 | |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function generateControllerContent($fileNamespace, $className, $modelClass) |
191 | 191 | { |
192 | - $alias = Inflector::humanize(Inflector::camel2words($className)); |
|
192 | + $alias = Inflector::humanize(Inflector::camel2words($className)); |
|
193 | 193 | return $this->view->render('@luya/console/commands/views/crud/create_controller.php', [ |
194 | 194 | 'namespace' => $fileNamespace, |
195 | 195 | 'className' => $className, |
196 | 196 | 'modelClass' => $modelClass, |
197 | 197 | 'luyaVersion' => $this->getGeneratorText('crud/create'), |
198 | - 'alias' => $alias, |
|
198 | + 'alias' => $alias, |
|
199 | 199 | ]); |
200 | 200 | } |
201 | 201 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields) |
213 | 213 | { |
214 | - $alias = Inflector::humanize(Inflector::camel2words($className)); |
|
214 | + $alias = Inflector::humanize(Inflector::camel2words($className)); |
|
215 | 215 | $dbTableName = $schema->fullName; |
216 | 216 | |
217 | 217 | $fields = []; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'properties' => $properties, |
260 | 260 | 'ngrestFieldConfig' => $ngrestFieldConfig, |
261 | 261 | 'i18nFields' => $i18nFields, |
262 | - 'alias' => $alias, |
|
262 | + 'alias' => $alias, |
|
263 | 263 | ]); |
264 | 264 | } |
265 | 265 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $this->apiEndpoint, |
367 | 367 | $this->getDbTableShema(), |
368 | 368 | $this->enableI18n |
369 | - ), |
|
369 | + ), |
|
370 | 370 | ]; |
371 | 371 | |
372 | 372 | foreach ($files as $file) { |
@@ -19,5 +19,5 @@ |
||
19 | 19 | /** |
20 | 20 | * @var string $modelClass The path to the model which is the provider for the rules and fields. |
21 | 21 | */ |
22 | - public $modelClass = '<?= $modelClass;?>'; |
|
22 | + public $modelClass = '<?= $modelClass; ?>'; |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -19,5 +19,5 @@ |
||
19 | 19 | /** |
20 | 20 | * @var string $modelClass The path to the model which is the provider for the rules and fields. |
21 | 21 | */ |
22 | - public $modelClass = '<?= $modelClass;?>'; |
|
22 | + public $modelClass = '<?= $modelClass; ?>'; |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * NgRest Model created with LUYA Version <?php echo $luyaVersion; ?>. |
12 | 12 | * |
13 | -<?php foreach ($properties as $name => $type): ?> * @property <?= $type; ?> $<?= $name . PHP_EOL; ?> |
|
14 | -<?php endforeach;?> |
|
13 | +<?php foreach ($properties as $name => $type): ?> * @property <?= $type; ?> $<?= $name.PHP_EOL; ?> |
|
14 | +<?php endforeach; ?> |
|
15 | 15 | */ |
16 | 16 | class <?= $className; ?> extends NgRestModel |
17 | 17 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public $i18n = ['<?= implode("', '", $textFields); ?>']; |
53 | 53 | |
54 | -<?php endif;?> |
|
54 | +<?php endif; ?> |
|
55 | 55 | /** |
56 | 56 | * @inheritdoc |
57 | 57 | */ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | return [ |
88 | 88 | <?php foreach ($ngrestFieldConfig as $name => $type): ?> |
89 | - '<?=$name; ?>' => '<?= $type;?>', |
|
89 | + '<?=$name; ?>' => '<?= $type; ?>', |
|
90 | 90 | <?php endforeach; ?>]; |
91 | 91 | } |
92 | 92 |