Skip to content

Commit

Permalink
move traversable check
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Jun 4, 2017
1 parent 298f707 commit 6306434
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/RepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,21 @@ protected function runManagerAction(string $action, $objects, bool $flush)
$manager->$action($object);
}

$this->flushObjects($objects instanceof \Traversable ? iterator_to_array($objects) : $objects, $flush);
$this->flushObjects($objects, $flush);
}

/**
* Flush managed objects.
*
* @param object|object[] $objects
* @param bool $flush
* @param object|object[]|\Traversable $objects
* @param bool $flush
*/
protected function flushObjects($objects, bool $flush)
{
if ($objects instanceof \Traversable) {
$objects = iterator_to_array($objects);
}

if ($flush || $this->autoFlush) {
$this->getManager()->flush($objects);
}
Expand Down

0 comments on commit 6306434

Please sign in to comment.