diff --git a/Nella/Doctrine/Service.php b/Nella/Doctrine/Service.php index c2488d6..b893041 100644 --- a/Nella/Doctrine/Service.php +++ b/Nella/Doctrine/Service.php @@ -60,13 +60,14 @@ protected function fillData(IEntity $entity, $values) foreach ($values as $key => $value) { $method = 'set' . ucfirst($key); - if (method_exists($entity, 'get' . ucfirst($key)) && (is_array($value) || $value instanceof \Traversable)) { + + if (method_exists($entity, $method)) { + $entity->$method($value); + } elseif (method_exists($entity, $method = 'get' . ucfirst($key)) && (is_array($value) || $value instanceof \Traversable)) { $entity->$method()->clear(); foreach ($value as $item) { $entity->$method()->add($item); } - } elseif (method_exists($entity, $method)) { - $entity->$method($value); } } }