From 4fed8e5a4668eb41a665275a1f03dc8275af99bf Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 5 Sep 2017 15:30:57 +0200 Subject: [PATCH] Bugfix if object already exists --- DataStorage/Database/DataMapperAbstract.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index d117baba4..15eff51a9 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -1498,6 +1498,8 @@ class DataMapperAbstract implements DataMapperInterface foreach ($primaryKey as $key => $value) { if(self::isInitialized(static::class, $value)) { + $obj[$value] = self::getInitialized(static::class, $value); + continue; } @@ -1911,6 +1913,21 @@ class DataMapperAbstract implements DataMapperInterface { return isset(self::$initObjects[$mapper]) && isset(self::$initObjects[$mapper][$id]); } + + /** + * Get initialized object + * + * @param string $mapper Mapper name + * @param mixed $id Object id + * + * @return object + * + * @since 1.0.0 + */ + private static function getInitialized($mapper, $id) + { + return self::$initObjects[$mapper][$id]; + } /** * Define the highest mapper of this request