Skip to content

Commit e42a73c

Browse files
authored
Merge pull request #1360 from phalcon/fix/#1320-scaffold-white-screen
#1320 - Fix Scaffold white screen
2 parents aeab393 + 1889733 commit e42a73c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Builder/Component/Scaffold.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public function build(): bool
181181
$attributes = $metaData->getAttributes($entity);
182182
$dataTypes = $metaData->getDataTypes($entity);
183183
$identityField = $metaData->getIdentityField($entity);
184+
$identityField = $identityField ? $identityField : null;
184185
$primaryKeys = $metaData->getPrimaryKeyAttributes($entity);
185186

186187
$setParams = [];
@@ -234,11 +235,11 @@ public function build(): bool
234235
*
235236
* @return string
236237
*/
237-
private function captureFilterInput(string $var, $fields, bool $useGetSetters, string $identityField): string
238+
private function captureFilterInput(string $var, $fields, bool $useGetSetters, string $identityField = null): string
238239
{
239240
$code = '';
240241
foreach ($fields as $field => $dataType) {
241-
if ($field == $identityField) {
242+
if ($identityField !== null && $field == $identityField) {
242243
continue;
243244
}
244245

@@ -502,28 +503,28 @@ private function makeController(): void
502503
$code = str_replace('$assignInputFromRequestCreate$', $this->captureFilterInput(
503504
$this->options->get('singular'),
504505
$this->options->get('dataTypes'),
505-
$this->options->get('genSettersGetters'),
506+
(bool) $this->options->get('genSettersGetters'),
506507
$this->options->get('identityField')
507508
), $code);
508509

509510
$code = str_replace('$assignInputFromRequestUpdate$', $this->captureFilterInput(
510511
$this->options->get('singular'),
511512
$this->options->get('dataTypes'),
512-
$this->options->get('genSettersGetters'),
513+
(bool) $this->options->get('genSettersGetters'),
513514
$this->options->get('identityField')
514515
), $code);
515516

516517
$code = str_replace('$assignTagDefaults$', $this->assignTagDefaults(
517518
$this->options->get('singular'),
518519
$this->options->get('dataTypes'),
519-
$this->options->get('genSettersGetters')
520+
(bool) $this->options->get('genSettersGetters')
520521
), $code);
521522

522523
$attributes = $this->options->get('attributes');
523524

524525
$code = str_replace('$pkVar$', '$' . $attributes[0], $code);
525526

526-
if ($this->options->get('genSettersGetters')) {
527+
if ((bool) $this->options->get('genSettersGetters')) {
527528
$code = str_replace('$pkGet$', 'get' . Text::camelize($attributes[0]) . '()', $code);
528529
} else {
529530
$code = str_replace('$pkGet$', $attributes[0], $code);

src/Web/Tools/Controllers/ScaffoldController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function generateAction()
5151
try {
5252
$tableName = $this->request->getPost('tableName', 'string');
5353

54-
$scaffoldBuilder = new Scaffold([
54+
$options = [
5555
'name' => $tableName,
5656
'schema' => $this->request->getPost('schema', 'string'),
5757
'force' => $this->request->getPost('force', 'int'),
@@ -60,8 +60,9 @@ public function generateAction()
6060
'templatePath' => $this->request->getPost('templatesPath', 'string'),
6161
'templateEngine' => $this->request->getPost('templateEngine', 'string'),
6262
'modelsNamespace' => $this->request->getPost('modelsNamespace', 'string'),
63-
]);
63+
];
6464

65+
$scaffoldBuilder = new Scaffold(array_merge($options, ['config' => $this->config->toArray()]));
6566
$scaffoldBuilder->build();
6667

6768
$this->flashSession->success(

0 commit comments

Comments
 (0)