/** * Inserts note * @param ServiceInterface $service * @param Contact $contact * @return self * @throws NotValidException * @todo throw more specific exception on invalid parent */ public function save(ServiceInterface $service, Contact $contact = null) { if (!$this->validate()) { throw new NotValidException('Unable to validate contact note'); } if ($contact === null) { throw new Exception('$contact must be instance of Contact'); } $newContact = $service->saveNote($this, $contact); $contact->setData($newContact->toArray(), false); return $this->reload(end($newContact->notes)); }