/** * @Route( * "/comment/{id}/update", * name="orocrm_case_comment_update", * requirements={"id"="\d+"} * ) * @AclAncestor("orocrm_case_comment_update") * @Template */ public function updateAction(CaseComment $comment) { $formAction = $this->get('router')->generate('orocrm_case_comment_update', ['id' => $comment->getId()]); $user = $this->getUser(); if ($user instanceof User) { $comment->setUpdatedBy($user); } return $this->update($comment, $formAction); }
/** * @param CaseComment $comment */ public function soapInit($comment) { $this->id = $comment->getId(); $this->message = $comment->getMessage(); $this->public = $comment->isPublic(); $this->case = $this->getEntityId($comment->getCase()); $this->contact = $this->getEntityId($comment->getContact()); $this->updatedBy = $this->getEntityId($comment->getUpdatedBy()); $this->owner = $this->getEntityId($comment->getOwner()); $this->createdAt = $comment->getCreatedAt(); $this->updatedAt = $comment->getUpdatedAt(); }
/** * @param CaseComment $comment * @return array */ public function createCommentView(CaseComment $comment) { $result = ['id' => $comment->getId(), 'message' => nl2br(htmlspecialchars($comment->getMessage())), 'briefMessage' => htmlspecialchars(mb_substr(preg_replace('/[\\n\\r]+/', ' ', $comment->getMessage()), 0, 200)), 'public' => $comment->isPublic(), 'createdAt' => $comment->getCreatedAt() ? $this->dateTimeFormatter->format($comment->getCreatedAt()) : null, 'updatedAt' => $comment->getUpdatedAt() ? $this->dateTimeFormatter->format($comment->getUpdatedAt()) : null, 'permissions' => array('edit' => $this->securityFacade->isGranted('EDIT', $comment), 'delete' => $this->securityFacade->isGranted('DELETE', $comment))]; if ($comment->getContact()) { $result['createdBy'] = $this->createAuthorView($comment->getContact()); } elseif ($comment->getOwner()) { $result['createdBy'] = $this->createAuthorView($comment->getOwner()); } if ($comment->getUpdatedBy()) { $result['updatedBy'] = $this->createAuthorView($comment->getUpdatedBy()); } return $result; }
public function testPreUpdate() { $this->assertNull($this->comment->getUpdatedAt()); $this->comment->preUpdate(); $this->assertInstanceOf('DateTime', $this->comment->getUpdatedAt()); $this->assertLessThan(3, $this->comment->getUpdatedAt()->diff(new \DateTime())->s); }