Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Monday Factory
Database model generator
Commits
0502946e
Commit
0502946e
authored
6 years ago
by
Petr Besir Horáček
Browse files
Options
Download
Patches
Plain Diff
Fixed generating Data::fromRow in cases without ro properties
parent
ec9786bd
master
beta
nette-3
php8
php82
0.0.1
No related merge requests found
Pipeline
#5017
failed with stage
in 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Generator/DataGenerator.php
+10
-4
src/Generator/DataGenerator.php
with
10 additions
and
4 deletions
+10
-4
src/Generator/DataGenerator.php
+
10
−
4
View file @
0502946e
...
...
@@ -63,7 +63,8 @@ class DataGenerator
$constructor
->
addParameter
(
$this
->
toCamelCase
(
$name
))
->
setTypeHint
(
$property
[
'type'
]);
$constructor
->
addComment
(
'@var $'
.
$this
->
toCamelCase
(
$name
));
$constructor
->
addComment
(
'@var '
.
$this
->
getTypehint
(
$property
[
'type'
])
.
' $'
.
$this
->
toCamelCase
(
$name
));
$constructor
->
addBody
(
'$this->? = ?;'
,
[
$this
->
toCamelCase
(
$name
),
new
PhpLiteral
(
'$'
.
$this
->
toCamelCase
(
$name
))]);
...
...
@@ -123,7 +124,11 @@ class DataGenerator
$fromRow
->
addParameter
(
'row'
)
->
setTypeHint
(
'array'
);
$fromRow
->
addBody
(
"return (new self("
);
if
(
isset
(
$this
->
definition
[
'databaseCols'
][
'ro'
])
&&
count
(
$this
->
definition
[
'databaseCols'
][
'ro'
])
>
0
)
{
$fromRow
->
addBody
(
"return (new self("
);
}
else
{
$fromRow
->
addBody
(
"return new self("
);
}
$rwProperties
=
$this
->
definition
[
'databaseCols'
][
'rw'
];
...
...
@@ -144,7 +149,7 @@ class DataGenerator
}
if
(
isset
(
$this
->
definition
[
'databaseCols'
][
'ro'
]))
{
if
(
isset
(
$this
->
definition
[
'databaseCols'
][
'ro'
])
&&
count
(
$this
->
definition
[
'databaseCols'
][
'ro'
])
>
0
)
{
$fromRow
->
addBody
(
"
\t
)
\n
)"
);
$roProperties
=
$this
->
definition
[
'databaseCols'
][
'ro'
];
...
...
@@ -159,8 +164,9 @@ class DataGenerator
$fromRow
->
addBody
(
"->set"
.
ucfirst
(
$this
->
toCamelCase
((
string
)
$name
))
.
"(
{
$pastedProperty
}
)"
.
$delimiter
);
}
}
else
{
$fromRow
->
addBody
(
"
\t
)
\n
);"
);
}
else
{
$fromRow
->
addBody
(
"
\t
);"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets