/** * Process all notes from request. * * @param Contact $contact The contact on which is worked * @param $notes * * @return bool True if the processing was successful, otherwise false */ public function processNotes($contact, $notes) { $get = function ($note) { return $note->getId(); }; $delete = function ($note) use($contact) { $contact->removeNote($note); return true; }; $update = function ($note, $matchedEntry) { return $this->updateNote($note, $matchedEntry); }; $add = function ($note) use($contact) { return $this->addNote($contact, $note); }; $entities = $contact->getNotes(); $result = $this->processSubEntities($entities, $notes, $get, $add, $update, $delete); $this->resetIndexOfSubentites($entities); return $result; }