Ejemplo n.º 1
0
 public function testIsNotUpdatedFlags()
 {
     $user = null;
     $date = null;
     $note = new Note();
     $note->setUpdatedBy($user);
     $note->setUpdatedAt($date);
     $this->assertFalse($note->isUpdatedBySet());
     $this->assertFalse($note->isUpdatedAtSet());
 }
 /**
  * "Success" form handler
  *
  * @param RFPRequest $rfpRequest
  */
 protected function onSuccess(RFPRequest $rfpRequest)
 {
     $status = $this->form->get('status')->getData();
     $noteMessage = trim($this->form->get('note')->getData());
     $rfpRequest->setStatus($status);
     if (!empty($noteMessage)) {
         $note = new Note();
         $note->setTarget($rfpRequest)->setMessage(htmlspecialchars_decode($this->templating->render('OroB2BRFPBundle:Request:note.html.twig', ['status' => $status->getLabel(), 'note' => $noteMessage])));
         $this->manager->persist($note);
     }
     $this->manager->flush();
 }
Ejemplo n.º 3
0
 /**
  * @param Note          $note
  * @param EntityManager $entityManager
  * @param bool          $update
  */
 protected function setUpdatedProperties(Note $note, EntityManager $entityManager, $update = false)
 {
     $newUpdatedAt = new \DateTime('now', new \DateTimeZone('UTC'));
     $newUpdatedBy = $this->getUser($entityManager);
     $unitOfWork = $entityManager->getUnitOfWork();
     if ($update && $newUpdatedBy != $note->getUpdatedBy()) {
         $unitOfWork->propertyChanged($note, 'updatedAt', $note->getUpdatedAt(), $newUpdatedAt);
         $unitOfWork->propertyChanged($note, 'updatedBy', $note->getUpdatedBy(), $newUpdatedBy);
     }
     $note->setUpdatedAt($newUpdatedAt);
     $note->setUpdatedBy($newUpdatedBy);
 }
Ejemplo n.º 4
0
 /**
  * @param Note $entity
  * @return array
  */
 public function getEntityViewModel(Note $entity)
 {
     $result = ['id' => $entity->getId(), 'message' => $entity->getMessage(), 'createdAt' => $entity->getCreatedAt()->format('c'), 'updatedAt' => $entity->getUpdatedAt()->format('c'), 'hasUpdate' => $entity->getCreatedAt() != $entity->getUpdatedAt(), 'editable' => $this->securityFacade->isGranted('EDIT', $entity), 'removable' => $this->securityFacade->isGranted('DELETE', $entity)];
     $this->addUser($result, 'createdBy', $entity->getOwner());
     $this->addUser($result, 'updatedBy', $entity->getUpdatedBy());
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * @param Note $entity
  *
  * {@inheritdoc}
  */
 public function getSubject($entity)
 {
     return $this->truncate(strip_tags($entity->getMessage()), 100);
 }
Ejemplo n.º 6
0
 /**
  * @Route("/update/{id}", name="oro_note_update", requirements={"id"="\d+"})
  *
  * @Template
  * @AclAncestor("oro_note_update")
  */
 public function updateAction(Note $entity)
 {
     $formAction = $this->get('router')->generate('oro_note_update', ['id' => $entity->getId()]);
     return $this->update($entity, $formAction);
 }
Ejemplo n.º 7
0
 public function testGettersSetters()
 {
     $note = new Note();
     $this->assertNull($note->getMessage());
     $this->assertNull($note->getId());
     $now = new \DateTime();
     $note->setCreatedAt($now)->setUpdatedAt($now)->setMessage('test');
     $this->assertEquals($now, $note->getCreatedAt());
     $this->assertEquals($now, $note->getUpdatedAt());
     $this->assertEquals('test', $note->getMessage());
     $user = new User();
     $note->setUpdatedBy($user)->setOwner($user);
     $this->assertSame($user, $note->getUpdatedBy());
     $this->assertEquals($user, $note->getOwner());
     $organization = new Organization();
     $this->assertNull($note->getOrganization());
     $note->setOrganization($organization);
     $this->assertSame($organization, $note->getOrganization());
 }