public function patchList($data)
{
$return = new ArrayCollection();
$results = $this->triggerDoctrineEvent(DoctrineResourceEvent::EVENT_PATCH_LIST_PRE, $data, $data);
if ($results->last() instanceof ApiProblem) {
return $results->last();
}
if (!$this->getObjectManager() instanceof EntityManagerInterface) {
throw new InvalidArgumentException('Invalid Object Manager, must implement EntityManagerInterface');
}
$this->getObjectManager()->getConnection()->beginTransaction();
foreach ($data as $row) {
$result = $this->patch($row[$this->getEntityIdentifierName()], $row);
if ($result instanceof ApiProblem) {
$this->getObjectManager()->getConnection()->rollback();
return $result;
}
$return->add($result);
}
$this->getObjectManager()->getConnection()->commit();
$results = $this->triggerDoctrineEvent(DoctrineResourceEvent::EVENT_PATCH_LIST_POST, $return, $data);
if ($results->last() instanceof ApiProblem) {
return $results->last();
}
return $return;
}