Ejemplo n.º 1
0
 /**
  * @param Note $note
  * @param ParameterBag $parameters
  * @param array $labels
  * @return Note
  */
 public function updateFromParameters(Note $note, ParameterBag $parameters, array $labels)
 {
     /** @var PersistentCollection $labels */
     $labelsSnapshot = $note->getLabels()->toArray();
     $toDelete = $this->getDeleteDiff($labelsSnapshot, $labels);
     array_walk($toDelete, [$note, 'removeLabel']);
     $toInsert = $this->getInsertDiff($labelsSnapshot, $labels);
     array_walk($toInsert, [$note, 'addLabel']);
     $this->update($note, $parameters);
     $this->getEntityManager()->flush();
     return $note;
 }