public function patch($id, $data)
{
$entity = $this->findEntity($id, 'patch', $data);
if ($entity instanceof ApiProblem) {
return $entity;
}
$results = $this->triggerDoctrineEvent(DoctrineResourceEvent::EVENT_PATCH_PRE, $entity, $data);
if ($results->last() instanceof ApiProblem) {
return $results->last();
}
// Hydrate entity with patched data
$this->getHydrator()->hydrate((array) $data, $entity);
$results = $this->triggerDoctrineEvent(DoctrineResourceEvent::EVENT_PATCH_POST, $entity, $data);
if ($results->last() instanceof ApiProblem) {
return $results->last();
}
$this->getObjectManager()->flush();
return $entity;
}