mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-04 03:38:42 +00:00
Fixing hasOne bugs
This commit is contained in:
parent
1535d8fdbe
commit
ba8a36043c
|
|
@ -268,11 +268,11 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$primaryKey = $relProperty->getValue($relObj);
|
$primaryKey = $relProperty->getValue($relObj);
|
||||||
$relProperty->setAccessible(false);
|
$relProperty->setAccessible(false);
|
||||||
|
|
||||||
if ($primaryKey !== 0 && $primaryKey !== null && $primaryKey !== '') {
|
if (empty($primaryKey)) {
|
||||||
$primaryKey = $mapper->create($property->getValue($relObj));
|
$primaryKey = $mapper->create($property->getValue($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$property->setValue($primaryKey);
|
$property->setValue($obj, $primaryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($column['internal'] === $pname) {
|
if ($column['internal'] === $pname) {
|
||||||
|
|
@ -336,7 +336,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$primaryKey = $relProperty->getValue($value);
|
$primaryKey = $relProperty->getValue($value);
|
||||||
$relProperty->setAccessible(false);
|
$relProperty->setAccessible(false);
|
||||||
|
|
||||||
if ($primaryKey !== 0 && $primaryKey !== null && $primaryKey !== '') {
|
if (!empty($primaryKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,16 +548,17 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
{
|
{
|
||||||
$reflectionClass = new \ReflectionClass(get_class($obj));
|
$reflectionClass = new \ReflectionClass(get_class($obj));
|
||||||
|
|
||||||
foreach (static::$hasOne as $column => $one) {
|
foreach (static::$hasOne as $member => $one) {
|
||||||
if ($reflectionClass->hasProperty(static::$columns[$column]['internal'])) {
|
// todo: is that if necessary? performance is suffering for sure!
|
||||||
$reflectionProperty = $reflectionClass->getProperty(static::$columns[$column]['internal']);
|
if ($reflectionClass->hasProperty($member)) {
|
||||||
|
$reflectionProperty = $reflectionClass->getProperty($member);
|
||||||
|
|
||||||
if (!($accessible = $reflectionProperty->isPublic())) {
|
if (!($accessible = $reflectionProperty->isPublic())) {
|
||||||
$reflectionProperty->setAccessible(true);
|
$reflectionProperty->setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var DataMapperAbstract $mapper */
|
/** @var DataMapperAbstract $mapper */
|
||||||
$mapper = static::$hasOne[$column]['mapper'];
|
$mapper = static::$hasOne[$member]['mapper'];
|
||||||
$mapper = new $mapper($this->db);
|
$mapper = new $mapper($this->db);
|
||||||
|
|
||||||
$value = $mapper->get($reflectionProperty->getValue($obj));
|
$value = $mapper->get($reflectionProperty->getValue($obj));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user