/**
  * 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('from')) {
         $from = $this->request->query->get('from');
         if (!empty($from)) {
             $this->preciseFullEmailAddress($from);
         }
         $model->setFrom($from);
     } else {
         $user = $this->getUser();
         if ($user) {
             $model->setFrom(EmailUtil::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->setTo(array($to));
     }
     if ($this->request->query->has('subject')) {
         $subject = trim($this->request->query->get('subject'));
         $model->setSubject($subject);
     }
 }
Beispiel #2
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);
     }
 }