Beispiel #1
0
 public function testHasEntity()
 {
     $obj = new Email();
     $this->assertFalse($obj->hasEntity());
     $obj->setEntityClass('Test\\Entity');
     $this->assertFalse($obj->hasEntity());
     $obj->setEntityId(123);
     $this->assertTrue($obj->hasEntity());
     $obj->setEntityClass(null);
     $this->assertFalse($obj->hasEntity());
 }
 public function testFormShouldBeSubmittendAndViewShouldContainsRouteParameters()
 {
     $email = new Email();
     $email->setEntityClass('entityClass_param');
     $email->setEntityId('entityId_param');
     $form = $this->factory->createBuilder('form', $email)->add('to', EmailAddressRecipientsType::NAME)->getForm();
     $form->submit([]);
     $expectedRouteParameters = ['entityClass' => 'entityClass_param', 'entityId' => 'entityId_param'];
     $view = $form->createView();
     $configs = $view->children['to']->vars['configs'];
     $this->assertTrue($form->isValid());
     $this->assertTrue($form->isSynchronized());
     $this->assertArrayHasKey('route_parameters', $configs);
     $this->assertEquals($configs['route_parameters'], $expectedRouteParameters);
 }
 /**
  * @param EmailModel  $emailModel
  * @param EmailEntity $emailEntity
  */
 protected function applyEntityDataFromEmail(EmailModel $emailModel, EmailEntity $emailEntity)
 {
     $entities = $emailEntity->getActivityTargetEntities();
     foreach ($entities as $entity) {
         if ($entity != $this->helper->getUser()) {
             $emailModel->setEntityClass(ClassUtils::getClass($entity));
             $emailModel->setEntityId($entity->getId());
             return;
         }
     }
 }
Beispiel #4
0
 /**
  * Populate a model with initial data.
  * This method is used to load an initial data from a query string
  *
  * @param Email $model
  */
 protected function initModel(Email $model)
 {
     if ($this->request->query->has('gridName')) {
         $model->setGridName($this->request->query->get('gridName'));
     }
     if ($this->request->query->has('entityClass')) {
         $model->setEntityClass($this->entityRoutingHelper->decodeClassName($this->request->query->get('entityClass')));
     }
     if ($this->request->query->has('entityId')) {
         $model->setEntityId($this->request->query->get('entityId'));
     }
     if ($this->request->query->has('from')) {
         $from = $this->request->query->get('from');
         if (!empty($from)) {
             $this->preciseFullEmailAddress($from);
         }
         $model->setFrom($from);
     } else {
         $user = $this->getUser();
         if ($user) {
             $model->setFrom($this->emailAddressHelper->buildFullEmailAddress($user->getEmail(), $this->nameFormatter->format($user)));
         }
     }
     if ($this->request->query->has('to')) {
         $to = trim($this->request->query->get('to'));
         if (!empty($to)) {
             $this->preciseFullEmailAddress($to, $model->getEntityClass(), $model->getEntityId());
         }
         $model->setTo(array($to));
     }
     if ($this->request->query->has('subject')) {
         $subject = trim($this->request->query->get('subject'));
         $model->setSubject($subject);
     }
 }