Skip to content

Commit

Permalink
Doctrine: fix service fillData for collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrtak-CZ committed Jul 17, 2011
1 parent ef2aafc commit 64609eb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Nella/Doctrine/Service.php
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 64609eb

Please sign in to comment.