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
8f2f2dc3
Commit
8f2f2dc3
authored
5 years ago
by
Petr Besir Horáček
Browse files
Options
Download
Patches
Plain Diff
Fixed resolving idFieldSerializer in collections
parent
8ab9aaa9
master
0.0.1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Generator/CollectionGenerator.php
+30
-0
src/Generator/CollectionGenerator.php
with
30 additions
and
0 deletions
+30
-0
src/Generator/CollectionGenerator.php
+
30
−
0
View file @
8f2f2dc3
...
...
@@ -37,6 +37,16 @@ class CollectionGenerator
$class
->
setExtends
(
BaseDatabaseDataCollection
::
class
);
if
(
isset
(
$this
->
definition
[
'databaseTableId'
])
&&
!
empty
(
$this
->
definition
[
'databaseTableId'
]))
{
$idFieldSerializer
=
$class
->
addProperty
(
'idFieldSerializer'
);
$idField
=
$this
->
findIdField
();
if
(
is_array
(
$idField
)
&&
isset
(
$idField
[
'toString'
]))
{
$idFieldSerializer
->
setValue
(
$idField
[
'toString'
]);
}
}
$methodCreate
=
$class
->
addMethod
(
'create'
);
$methodCreate
->
addBody
(
'return new static($data, ?, $idField);'
,
[
new
PhpLiteral
(
$this
->
getRowFactoryClassName
()
.
'::class'
)])
...
...
@@ -56,4 +66,24 @@ class CollectionGenerator
return
(
string
)
$file
;
}
private
function
findIdField
():
?array
{
if
(
isset
(
$this
->
definition
[
'databaseCols'
][
'rw'
])
&&
isset
(
$this
->
definition
[
'databaseCols'
][
'rw'
][
$this
->
definition
[
'databaseTableId'
]]
)
)
{
return
$this
->
definition
[
'databaseCols'
][
'rw'
][
$this
->
definition
[
'databaseTableId'
]];
}
else
if
(
isset
(
$this
->
definition
[
'databaseCols'
][
'rw'
])
&&
isset
(
$this
->
definition
[
'databaseCols'
][
'ro'
][
$this
->
definition
[
'databaseTableId'
]]
)
)
{
return
$this
->
definition
[
'databaseCols'
][
'ro'
][
$this
->
definition
[
'databaseTableId'
]];
}
return
null
;
}
}
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