mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 14:38:39 +00:00
adjust conditional impl. This now allows to use conditionals without a column reference
This commit is contained in:
parent
644af71b73
commit
29e448c3bd
|
|
@ -1960,7 +1960,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
? $mapper::get($values, RelationType::ALL, $depth)
|
? $mapper::get($values, RelationType::ALL, $depth)
|
||||||
: $mapper::get($values, RelationType::ALL, $depth, static::$hasMany[$member]['by']);
|
: $mapper::get($values, RelationType::ALL, $depth, static::$hasMany[$member]['by']);
|
||||||
|
|
||||||
$refProp->setValue($obj, !\is_array($objects) ? [$mapper::getObjectId($objects) => $objects] : $objects);
|
$refProp->setValue($obj, !\is_array($objects) && !isset(static::$hasMany[$member]['conditional']) ? [$mapper::getObjectId($objects) => $objects] : $objects);
|
||||||
|
|
||||||
if (!$accessible) {
|
if (!$accessible) {
|
||||||
$refProp->setAccessible(false);
|
$refProp->setAccessible(false);
|
||||||
|
|
@ -1983,7 +1983,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
{
|
{
|
||||||
foreach ($result as $member => $values) {
|
foreach ($result as $member => $values) {
|
||||||
if (empty($values)
|
if (empty($values)
|
||||||
|| isset(static::$hasMany[$member]['column']) // handled in getQuery()
|
|| isset(static::$hasMany[$member]['conditional']) // handled in getQuery()
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -3136,7 +3136,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
// get OwnsOneQuery
|
// get OwnsOneQuery
|
||||||
if ($depth > 1 && self::$relations === RelationType::ALL) {
|
if ($depth > 1 && self::$relations === RelationType::ALL) {
|
||||||
foreach (static::$ownsOne as $member => $rel) {
|
foreach (static::$ownsOne as $rel) {
|
||||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
||||||
->on(
|
->on(
|
||||||
static::$table . '_' . $depth . '.' . $rel['self'], '=',
|
static::$table . '_' . $depth . '.' . $rel['self'], '=',
|
||||||
|
|
@ -3157,7 +3157,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
// get BelognsToQuery
|
// get BelognsToQuery
|
||||||
if ($depth > 1 && self::$relations === RelationType::ALL) {
|
if ($depth > 1 && self::$relations === RelationType::ALL) {
|
||||||
foreach (static::$belongsTo as $member => $rel) {
|
foreach (static::$belongsTo as $rel) {
|
||||||
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
$query->leftJoin($rel['mapper']::getTable(), $rel['mapper']::getTable() . '_' . ($depth - 1))
|
||||||
->on(
|
->on(
|
||||||
static::$table . '_' . $depth . '.' . $rel['self'], '=',
|
static::$table . '_' . $depth . '.' . $rel['self'], '=',
|
||||||
|
|
@ -3178,7 +3178,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
// get HasManyQuery (but only for elements which have a 'column' defined)
|
// get HasManyQuery (but only for elements which have a 'column' defined)
|
||||||
if ($depth > 1 && self::$relations === RelationType::ALL) {
|
if ($depth > 1 && self::$relations === RelationType::ALL) {
|
||||||
foreach (static::$hasMany as $member => $rel) {
|
foreach (static::$hasMany as $rel) {
|
||||||
if (isset($rel['self']) || !isset($rel['column'])) { // @todo: conflict with getHasMany()???!?!?!?!
|
if (isset($rel['self']) || !isset($rel['column'])) { // @todo: conflict with getHasMany()???!?!?!?!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ class BaseModelMapper extends DataMapperAbstract
|
||||||
'table' => 'test_conditional',
|
'table' => 'test_conditional',
|
||||||
'external' => 'test_conditional_base',
|
'external' => 'test_conditional_base',
|
||||||
'column' => 'title',
|
'column' => 'title',
|
||||||
|
'conditional' => true,
|
||||||
'self' => null,
|
'self' => null,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user