WeaponOwl
Active member
Hello. I see very strange behaviour. I have entity 'MissionRecord' with
i receive
All fine here, system look great, just small limitation, no problem. I load another entities for
If i not load 'NpcMissionRecord' by php code, before move parameters to template, no relations as part of 'MissionRecord' entity in template, there should just no relation inside entity variable, at least dump inside tempate or php code return next
No relations without pre-load it inside php code. But right after use
Why xf load
Now i need think how for template hide no needed relations or another set of variables, becouse even if i just want check load i relations or not, relations become exist.
I confused.
Edit: This feature useful, this is not problem in general, but why it work?
TO_MANY
relation to 'NpcMissionRecord', if try load this entity with relation using default finder
Code:
$this->finder('.../MissionRecord')
->with('NpcMissionRecord')
->where('id', $id)
->fetch();
Exception: Joins only support TO_ONE relationships currently
, so need make new code with using hydrateRelation
All fine here, system look great, just small limitation, no problem. I load another entities for
TO_MANY
relation without using ->with(...)
in first finder, combine both sets with hydrateRelation
. And then use this combined entities in tempate
Code:
<xf:foreach loop="$missions" value="$mission">
...
<xf:if is="$mission.NpcMissionRecord is not empty">
<xf:foreach loop="{$mission.NpcMissionRecord}" value="$missionNpcRecord">
...
</xf:foreach>
</xf:if>
...
</xf:foreach>
If i not load 'NpcMissionRecord' by php code, before move parameters to template, no relations as part of 'MissionRecord' entity in template, there should just no relation inside entity variable, at least dump inside tempate or php code return next
Code:
MissionRecord {#254 ▼
-_uniqueEntityId: 5
...
#_values: array:19 [▼
...
]
#_relations: []
...
}
No relations without pre-load it inside php code. But right after use
<xf:if is="$mission.NpcMissionRecord is not empty">
inside template, this relations write to entity, even if there wasn't pre-load. Right after use <xf:if is="$mission.NpcMissionRecord is not empty">
or just {{ $mission.NpcMissionRecord }}
i have next
Code:
MissionRecord {#254 ▼
-_uniqueEntityId: 5
...
#_values: array:19 [▼
...
]
#_relations: array:1 [▼
"NpcMissionRecord" => ArrayCollection {#328 ▼
#entities: array:1 [▼
28 => NpcMissionRecord {#321 ▼
-_uniqueEntityId: 62
...
#_values: array:6 [▼
...
]
...
}
]
#populated: true
}
]
...
}
Why xf load
TO_MANY
relation even when i no need it? Why i should use code what found in entities needed parameters, load another entities for with this parameters, combine both sets, while xf template can do it with a flick of the fingers? This is undocumented feature or manually limitation for developers?Now i need think how for template hide no needed relations or another set of variables, becouse even if i just want check load i relations or not, relations become exist.
I confused.
Edit: This feature useful, this is not problem in general, but why it work?
Last edited: