public function updateComment(Comment $c) { if ($c === null) { throw new Exceptions\NullPointerException("Argument comment was null"); } try { $cDb = $this->commentDao->find($c->getId()); if ($cDb !== null) { $cDb->fromArray($c->toArray()); $cDb->setUpdated(new DateTime()); $this->authorTypeHandle($cDb); $this->entityManager->merge($cDb); $this->entityManager->flush(); $this->invalidateEntityCache($c); $this->onUpdate($c); } } catch (\Exception $ex) { throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }
public function deleteComment(Comment $c, ICommentable $e) { try { $wpDb = $this->wallDao->find($e->getId()); if ($wpDb !== null) { $coll = $wpDb->getComments(); $id = $c->getId(); $comment = $coll->filter(function ($e) use($id) { return $e->getId() == $id; })->first(); $index = $coll->indexOf($comment); $coll->remove($index); $this->entityManager->merge($wpDb); $this->entityManager->flush($wpDb); $this->commentService->deleteComment($c->getId()); $this->invalidateEntityCache($wpDb); } } catch (Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } }