コード例 #1
0
 /**
  * @param      $objectId
  * @param bool $ignorePost
  * @param bool $forceTypeSelection
  *
  * @return array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function editAction($objectId, $ignorePost = false, $forceTypeSelection = false)
 {
     /** @var \Mautic\EmailBundle\Model\EmailModel $model */
     $model = $this->factory->getModel('email');
     $entity = $model->getEntity($objectId);
     $session = $this->factory->getSession();
     $page = $this->factory->getSession()->get('mautic.email.page', 1);
     //set the return URL
     $returnUrl = $this->generateUrl('mautic_email_index', array('page' => $page));
     $postActionVars = array('returnUrl' => $returnUrl, 'viewParameters' => array('page' => $page), 'contentTemplate' => 'MauticEmailBundle:Email:index', 'passthroughVars' => array('activeLink' => 'mautic_email_index', 'mauticContent' => 'email'));
     //not found
     if ($entity === null) {
         return $this->postActionRedirect(array_merge($postActionVars, array('flashes' => array(array('type' => 'error', 'msg' => 'mautic.email.error.notfound', 'msgVars' => array('%id%' => $objectId))))));
     } elseif (!$this->factory->getSecurity()->hasEntityAccess('email:emails:viewown', 'email:emails:viewother', $entity->getCreatedBy())) {
         return $this->accessDenied();
     } elseif ($entity->getEmailType() == 'list' && $entity->getSentCount()) {
         return $this->postActionRedirect(array_merge($postActionVars, array('flashes' => array(array('type' => 'error', 'msg' => 'mautic.email.error.list_type.sent', 'msgVars' => array('%name%' => $entity->getName()))))));
     } elseif ($model->isLocked($entity)) {
         //deny access if the entity is locked
         return $this->isLocked($postActionVars, $entity, 'email');
     }
     //Create the form
     $action = $this->generateUrl('mautic_email_action', array('objectAction' => 'edit', 'objectId' => $objectId));
     $form = $model->createForm($entity, $this->get('form.factory'), $action);
     ///Check for a submitted form and process it
     if (!$ignorePost && $this->request->getMethod() == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $contentName = 'mautic.emailbuilder.' . $entity->getSessionId() . '.content';
                 $template = $entity->getTemplate();
                 if (!empty($template)) {
                     $existingContent = $entity->getContent();
                     $newContent = $session->get($contentName, array());
                     $viewContent = array_merge($existingContent, $newContent);
                     $entity->setCustomHtml(null);
                 } else {
                     $entity->setContent(array());
                     $viewContent = $entity->getCustomHtml();
                 }
                 // Copy model content then parse from visual to tokens
                 $modelContent = $viewContent;
                 BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($modelContent);
                 if (!empty($template)) {
                     $entity->setContent($modelContent);
                 } else {
                     $entity->setCustomHtml($modelContent);
                 }
                 //form is valid so process the data
                 $model->saveEntity($entity, $form->get('buttons')->get('save')->isClicked());
                 //clear the session
                 $session->remove($contentName);
                 $this->addFlash('mautic.core.notice.updated', array('%name%' => $entity->getName(), '%menu_link%' => 'mautic_email_index', '%url%' => $this->generateUrl('mautic_email_action', array('objectAction' => 'edit', 'objectId' => $entity->getId()))), 'warning');
             }
         } else {
             //clear any modified content
             $session->remove('mautic.emailbuilder.' . $objectId . '.content');
             //unlock the entity
             $model->unlockEntity($entity);
         }
         if ($cancelled || $valid && $form->get('buttons')->get('save')->isClicked()) {
             $viewParameters = array('objectAction' => 'view', 'objectId' => $entity->getId());
             return $this->postActionRedirect(array_merge($postActionVars, array('returnUrl' => $this->generateUrl('mautic_email_action', $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => 'MauticEmailBundle:Email:view')));
         }
     } else {
         //lock the entity
         $model->lockEntity($entity);
         //clear any modified content
         $session->remove('mautic.emailbuilder.' . $objectId . '.content');
         // Parse tokens into view data
         $tokens = $model->getBuilderComponents($entity, array('tokens', 'visualTokens', 'tokenSections'));
         // Set to view content
         $template = $entity->getTemplate();
         if (empty($template)) {
             $content = $entity->getCustomHtml();
             BuilderTokenHelper::replaceTokensWithVisualPlaceholders($tokens, $content);
             $form['customHtml']->setData($content);
         }
     }
     $assets = $form['assetAttachments']->getData();
     $attachmentSize = $this->factory->getModel('asset')->getTotalFilesize($assets);
     return $this->delegateView(array('viewParameters' => array('form' => $this->setFormTheme($form, 'MauticEmailBundle:Email:form.html.php', 'MauticEmailBundle:FormTheme\\Email'), 'tokens' => !empty($tokens) ? $tokens['tokenSections'] : $model->getBuilderComponents($entity, 'tokenSections'), 'email' => $entity, 'forceTypeSelection' => $forceTypeSelection, 'attachmentSize' => $attachmentSize), 'contentTemplate' => 'MauticEmailBundle:Email:form.html.php', 'passthroughVars' => array('activeLink' => '#mautic_email_index', 'mauticContent' => 'email', 'route' => $this->generateUrl('mautic_email_action', array('objectAction' => 'edit', 'objectId' => $entity->getId())))));
 }
コード例 #2
0
 /**
  * @param int $objectId
  *
  * @return JsonResponse
  */
 protected function emailAction($objectId = 0)
 {
     $valid = $cancelled = false;
     /** @var \Mautic\LeadBundle\Model\LeadModel $model */
     $model = $this->factory->getModel('lead');
     /** @var \Mautic\LeadBundle\Entity\Lead $lead */
     $lead = $model->getEntity($objectId);
     if ($lead === null || !$this->factory->getSecurity()->hasEntityAccess('lead:leads:viewown', 'lead:leads:viewother', $lead->getOwner())) {
         return $this->modalAccessDenied();
     }
     $leadFields = $model->flattenFields($lead->getFields());
     $leadFields['id'] = $lead->getId();
     $leadEmail = $leadFields['email'];
     $leadName = $leadFields['firstname'] . ' ' . $leadFields['lastname'];
     $inList = $this->request->getMethod() == 'GET' ? $this->request->get('list', 0) : $this->request->request->get('lead_quickemail[list]', 0, true);
     $email = array('list' => $inList);
     $action = $this->generateUrl('mautic_lead_action', array('objectAction' => 'email', 'objectId' => $objectId));
     $form = $this->get('form.factory')->create('lead_quickemail', $email, array('action' => $action));
     if ($this->request->getMethod() == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $email = $form->getData();
                 $bodyCheck = trim(strip_tags($email['body']));
                 if (!empty($bodyCheck)) {
                     $mailer = $this->factory->getMailer();
                     // To lead
                     $mailer->addTo($leadEmail, $leadName);
                     // From user
                     $user = $this->factory->getUser();
                     $mailer->setFrom($email['from'], strtolower($user->getEmail()) !== strtolower($email['from']) ? null : $user->getFirstName() . ' ' . $user->getLastName());
                     // Set Content
                     BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($email['body']);
                     $mailer->setBody($email['body']);
                     $mailer->parsePlainText($email['body']);
                     // Set lead
                     $mailer->setLead($leadFields);
                     $mailer->setIdHash();
                     $mailer->setSubject($email['subject']);
                     if ($error = $mailer->send(true)) {
                         $mailer->createLeadEmailStat();
                         $this->addFlash('mautic.lead.email.notice.sent', array('%subject%' => $email['subject'], '%email%' => $leadEmail));
                     } else {
                         $this->addFlash('mautic.lead.email.error.failed', array('%subject%' => $email['subject'], '%email%' => $leadEmail));
                     }
                 } else {
                     $form['body']->addError(new FormError($this->get('translator')->trans('mautic.lead.email.body.required', array(), 'validators')));
                     $valid = false;
                 }
             }
         }
     }
     if (empty($leadEmail) || $valid || $cancelled) {
         if ($inList) {
             $route = 'mautic_lead_index';
             $viewParameters = array('page' => $this->factory->getSession()->get('mautic.lead.page', 1));
             $func = 'index';
         } else {
             $route = 'mautic_lead_action';
             $viewParameters = array('objectAction' => 'view', 'objectId' => $objectId);
             $func = 'view';
         }
         return $this->postActionRedirect(array('returnUrl' => $this->generateUrl($route, $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => 'MauticLeadBundle:Lead:' . $func, 'passthroughVars' => array('mauticContent' => 'lead', 'closeModal' => 1)));
     }
     return $this->ajaxAction(array('contentTemplate' => 'MauticLeadBundle:Lead:email.html.php', 'viewParameters' => array('form' => $form->createView()), 'passthroughVars' => array('mauticContent' => 'leadEmail', 'route' => false)));
 }
コード例 #3
0
ファイル: AjaxController.php プロジェクト: HomeRefill/mautic
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function generatePlaintTextAction(Request $request)
 {
     $dataArray = array();
     $mode = $request->request->get('mode');
     $custom = $request->request->get('custom');
     $id = $request->request->get('id');
     $parser = new PlainTextHelper(array('base_url' => $request->getSchemeAndHttpHost() . $request->getBasePath()));
     if ($mode == 'custom') {
         // Convert placeholders into raw tokens
         BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($custom);
         $dataArray['text'] = $parser->setHtml($custom)->getText();
     } else {
         $session = $this->factory->getSession();
         $contentName = 'mautic.emailbuilder.' . $id . '.content';
         $content = $session->get($contentName, array());
         if (strpos($id, 'new') === false) {
             $entity = $this->factory->getModel('email')->getEntity($id);
             $existingContent = $entity->getContent();
             $content = array_merge($existingContent, $content);
         }
         // Convert placeholders into raw tokens
         BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($content);
         $content = implode("<br /><br />", $content);
         $dataArray['text'] = $parser->setHtml($content)->getText();
     }
     return $this->sendJsonResponse($dataArray);
 }
コード例 #4
0
ファイル: AjaxController.php プロジェクト: dongilbert/mautic
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function generatePlaintTextAction(Request $request)
 {
     $custom = $request->request->get('custom');
     $id = $request->request->get('id');
     $parser = new PlainTextHelper(['base_url' => $request->getSchemeAndHttpHost() . $request->getBasePath()]);
     // Convert placeholders into raw tokens
     BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($custom);
     $dataArray = ['text' => $parser->setHtml($custom)->getText()];
     return $this->sendJsonResponse($dataArray);
 }
コード例 #5
0
ファイル: PageController.php プロジェクト: dongilbert/mautic
 /**
  * Generates edit form and processes post data.
  *
  * @param int  $objectId
  * @param bool $ignorePost
  *
  * @return JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function editAction($objectId, $ignorePost = false)
 {
     /** @var \Mautic\PageBundle\Model\PageModel $model */
     $model = $this->getModel('page.page');
     $entity = $model->getEntity($objectId);
     $session = $this->get('session');
     $page = $this->get('session')->get('mautic.page.page', 1);
     //set the return URL
     $returnUrl = $this->generateUrl('mautic_page_index', ['page' => $page]);
     $postActionVars = ['returnUrl' => $returnUrl, 'viewParameters' => ['page' => $page], 'contentTemplate' => 'MauticPageBundle:Page:index', 'passthroughVars' => ['activeLink' => 'mautic_page_index', 'mauticContent' => 'page']];
     //not found
     if ($entity === null) {
         return $this->postActionRedirect(array_merge($postActionVars, ['flashes' => [['type' => 'error', 'msg' => 'mautic.page.error.notfound', 'msgVars' => ['%id%' => $objectId]]]]));
     } elseif (!$this->get('mautic.security')->hasEntityAccess('page:pages:viewown', 'page:pages:viewother', $entity->getCreatedBy())) {
         return $this->accessDenied();
     } elseif ($model->isLocked($entity)) {
         //deny access if the entity is locked
         return $this->isLocked($postActionVars, $entity, 'page.page');
     }
     //Create the form
     $action = $this->generateUrl('mautic_page_action', ['objectAction' => 'edit', 'objectId' => $objectId]);
     $form = $model->createForm($entity, $this->get('form.factory'), $action);
     ///Check for a submitted form and process it
     if (!$ignorePost && $this->request->getMethod() == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $content = $entity->getCustomHtml();
                 BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($content);
                 $entity->setCustomHtml($content);
                 //form is valid so process the data
                 $model->saveEntity($entity, $form->get('buttons')->get('save')->isClicked());
                 $this->addFlash('mautic.core.notice.updated', ['%name%' => $entity->getTitle(), '%menu_link%' => 'mautic_page_index', '%url%' => $this->generateUrl('mautic_page_action', ['objectAction' => 'edit', 'objectId' => $entity->getId()])]);
             }
         } else {
             //clear any modified content
             $session->remove('mautic.pagebuilder.' . $objectId . '.content');
             //unlock the entity
             $model->unlockEntity($entity);
         }
         if ($cancelled || $valid && $form->get('buttons')->get('save')->isClicked()) {
             $viewParameters = ['objectAction' => 'view', 'objectId' => $entity->getId()];
             return $this->postActionRedirect(array_merge($postActionVars, ['returnUrl' => $this->generateUrl('mautic_page_action', $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => 'MauticPageBundle:Page:view']));
         }
     } else {
         //lock the entity
         $model->lockEntity($entity);
         //clear any modified content
         $session->remove('mautic.pagebuilder.' . $objectId . '.content');
         //set the lookup values
         $parent = $entity->getTranslationParent();
         if ($parent && isset($form['translationParent_lookup'])) {
             $form->get('translationParent_lookup')->setData($parent->getTitle());
         }
         // Parse tokens into view data
         $tokens = $model->getBuilderComponents($entity, ['tokens', 'visualTokens', 'tokenSections']);
         // Set to view content
         $template = $entity->getTemplate();
         if (empty($template)) {
             $content = $entity->getCustomHtml();
             $form['customHtml']->setData($content);
         }
     }
     $slotTypes = $model->getBuilderComponents($entity, 'slotTypes');
     $sectionForm = $this->get('form.factory')->create('builder_section');
     return $this->delegateView(['viewParameters' => ['form' => $this->setFormTheme($form, 'MauticPageBundle:Page:form.html.php', 'MauticPageBundle:FormTheme\\Page'), 'isVariant' => $entity->isVariant(true), 'tokens' => !empty($tokens) ? $tokens['tokenSections'] : $model->getBuilderComponents($entity, 'tokenSections'), 'activePage' => $entity, 'themes' => $this->factory->getInstalledThemes('page', true), 'slots' => $this->buildSlotForms($slotTypes), 'builderAssets' => trim(preg_replace('/\\s+/', ' ', $this->getAssetsForBuilder())), 'sectionForm' => $sectionForm->createView()], 'contentTemplate' => 'MauticPageBundle:Page:form.html.php', 'passthroughVars' => ['activeLink' => '#mautic_page_index', 'mauticContent' => 'page', 'route' => $this->generateUrl('mautic_page_action', ['objectAction' => 'edit', 'objectId' => $entity->getId()])]]);
 }
コード例 #6
0
ファイル: LeadController.php プロジェクト: dongilbert/mautic
 /**
  * @param int $objectId
  *
  * @return JsonResponse
  */
 public function emailAction($objectId = 0)
 {
     $valid = $cancelled = false;
     /** @var \Mautic\LeadBundle\Model\LeadModel $model */
     $model = $this->getModel('lead');
     /** @var \Mautic\LeadBundle\Entity\Lead $lead */
     $lead = $model->getEntity($objectId);
     if ($lead === null || !$this->get('mautic.security')->hasEntityAccess('lead:leads:viewown', 'lead:leads:viewother', $lead->getPermissionUser())) {
         return $this->modalAccessDenied();
     }
     $leadFields = $lead->getProfileFields();
     $leadFields['id'] = $lead->getId();
     $leadEmail = $leadFields['email'];
     $leadName = $leadFields['firstname'] . ' ' . $leadFields['lastname'];
     // Set onwer ID to be the current user ID so it will use his signature
     $leadFields['owner_id'] = $this->get('mautic.helper.user')->getUser()->getId();
     // Check if lead has a bounce status
     /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
     $emailModel = $this->getModel('email');
     $dnc = $emailModel->getRepository()->checkDoNotEmail($leadEmail);
     $inList = $this->request->getMethod() == 'GET' ? $this->request->get('list', 0) : $this->request->request->get('lead_quickemail[list]', 0, true);
     $email = ['list' => $inList];
     $action = $this->generateUrl('mautic_contact_action', ['objectAction' => 'email', 'objectId' => $objectId]);
     $form = $this->get('form.factory')->create('lead_quickemail', $email, ['action' => $action]);
     if ($this->request->getMethod() == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $email = $form->getData();
                 $bodyCheck = trim(strip_tags($email['body']));
                 if (!empty($bodyCheck)) {
                     $mailer = $this->get('mautic.helper.mailer')->getMailer();
                     // To lead
                     $mailer->addTo($leadEmail, $leadName);
                     // From user
                     $user = $this->get('mautic.helper.user')->getUser();
                     $mailer->setFrom($email['from'], empty($email['fromname']) ? '' : $email['fromname']);
                     // Set Content
                     BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($email['body']);
                     $mailer->setBody($email['body']);
                     $mailer->parsePlainText($email['body']);
                     // Set lead
                     $mailer->setLead($leadFields);
                     $mailer->setIdHash();
                     $mailer->setSubject($email['subject']);
                     // Ensure safe emoji for notification
                     $subject = EmojiHelper::toHtml($email['subject']);
                     if ($mailer->send(true, false, false)) {
                         $mailer->createEmailStat();
                         $this->addFlash('mautic.lead.email.notice.sent', ['%subject%' => $subject, '%email%' => $leadEmail]);
                     } else {
                         $errors = $mailer->getErrors();
                         // Unset the array of failed email addresses
                         if (isset($errors['failures'])) {
                             unset($errors['failures']);
                         }
                         $form->addError(new FormError($this->get('translator')->trans('mautic.lead.email.error.failed', ['%subject%' => $subject, '%email%' => $leadEmail, '%error%' => is_array($errors) ? implode('<br />', $errors) : $errors], 'flashes')));
                         $valid = false;
                     }
                 } else {
                     $form['body']->addError(new FormError($this->get('translator')->trans('mautic.lead.email.body.required', [], 'validators')));
                     $valid = false;
                 }
             }
         }
     }
     if (empty($leadEmail) || $valid || $cancelled) {
         if ($inList) {
             $route = 'mautic_contact_index';
             $viewParameters = ['page' => $this->get('session')->get('mautic.lead.page', 1)];
             $func = 'index';
         } else {
             $route = 'mautic_contact_action';
             $viewParameters = ['objectAction' => 'view', 'objectId' => $objectId];
             $func = 'view';
         }
         return $this->postActionRedirect(['returnUrl' => $this->generateUrl($route, $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => 'MauticLeadBundle:Lead:' . $func, 'passthroughVars' => ['mauticContent' => 'lead', 'closeModal' => 1]]);
     }
     return $this->ajaxAction(['contentTemplate' => 'MauticLeadBundle:Lead:email.html.php', 'viewParameters' => ['form' => $form->createView(), 'dnc' => $dnc], 'passthroughVars' => ['mauticContent' => 'leadEmail', 'route' => false]]);
 }
コード例 #7
0
ファイル: EmailController.php プロジェクト: dongilbert/mautic
 /**
  * @param      $objectId
  * @param bool $ignorePost
  * @param bool $forceTypeSelection
  *
  * @return array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function editAction($objectId, $ignorePost = false, $forceTypeSelection = false)
 {
     /** @var \Mautic\EmailBundle\Model\EmailModel $model */
     $model = $this->getModel('email');
     $method = $this->request->getMethod();
     $entity = $model->getEntity($objectId);
     $session = $this->get('session');
     $page = $this->get('session')->get('mautic.email.page', 1);
     //set the return URL
     $returnUrl = $this->generateUrl('mautic_email_index', ['page' => $page]);
     $postActionVars = ['returnUrl' => $returnUrl, 'viewParameters' => ['page' => $page], 'contentTemplate' => 'MauticEmailBundle:Email:index', 'passthroughVars' => ['activeLink' => 'mautic_email_index', 'mauticContent' => 'email']];
     //not found
     if ($entity === null) {
         return $this->postActionRedirect(array_merge($postActionVars, ['flashes' => [['type' => 'error', 'msg' => 'mautic.email.error.notfound', 'msgVars' => ['%id%' => $objectId]]]]));
     } elseif (!$this->get('mautic.security')->hasEntityAccess('email:emails:editown', 'email:emails:editother', $entity->getCreatedBy())) {
         return $this->accessDenied();
     } elseif ($model->isLocked($entity)) {
         //deny access if the entity is locked
         return $this->isLocked($postActionVars, $entity, 'email');
     }
     //Create the form
     $action = $this->generateUrl('mautic_email_action', ['objectAction' => 'edit', 'objectId' => $objectId]);
     $updateSelect = $method == 'POST' ? $this->request->request->get('emailform[updateSelect]', false, true) : $this->request->get('updateSelect', false);
     if ($updateSelect) {
         // Force type to template
         $entity->setEmailType('template');
     }
     $form = $model->createForm($entity, $this->get('form.factory'), $action, ['update_select' => $updateSelect]);
     ///Check for a submitted form and process it
     if (!$ignorePost && $method == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $content = $entity->getCustomHtml();
                 BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($content);
                 $entity->setCustomHtml($content);
                 //form is valid so process the data
                 $model->saveEntity($entity, $form->get('buttons')->get('save')->isClicked());
                 $this->addFlash('mautic.core.notice.updated', ['%name%' => $entity->getName(), '%menu_link%' => 'mautic_email_index', '%url%' => $this->generateUrl('mautic_email_action', ['objectAction' => 'edit', 'objectId' => $entity->getId()])], 'warning');
             }
         } else {
             //clear any modified content
             $session->remove('mautic.emailbuilder.' . $objectId . '.content');
             //unlock the entity
             $model->unlockEntity($entity);
         }
         $template = 'MauticEmailBundle:Email:view';
         $passthrough = ['activeLink' => 'mautic_email_index', 'mauticContent' => 'email'];
         // Check to see if this is a popup
         if (isset($form['updateSelect'])) {
             $template = false;
             $passthrough = array_merge($passthrough, ['updateSelect' => $form['updateSelect']->getData(), 'emailId' => $entity->getId(), 'emailSubject' => $entity->getSubject(), 'emailName' => $entity->getName(), 'emailLang' => $entity->getLanguage()]);
         }
         if ($cancelled || $valid && $form->get('buttons')->get('save')->isClicked()) {
             $viewParameters = ['objectAction' => 'view', 'objectId' => $entity->getId()];
             return $this->postActionRedirect(array_merge($postActionVars, ['returnUrl' => $this->generateUrl('mautic_email_action', $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => $template, 'passthroughVars' => $passthrough]));
         }
     } else {
         //lock the entity
         $model->lockEntity($entity);
         //clear any modified content
         $session->remove('mautic.emailbuilder.' . $objectId . '.content');
         // Parse tokens into view data
         $tokens = $model->getBuilderComponents($entity, ['tokens', 'visualTokens', 'tokenSections']);
         // Set to view content
         $template = $entity->getTemplate();
         if (empty($template)) {
             $content = $entity->getCustomHtml();
             $form['customHtml']->setData($content);
         }
     }
     $assets = $form['assetAttachments']->getData();
     $attachmentSize = $this->getModel('asset')->getTotalFilesize($assets);
     $slotTypes = $model->getBuilderComponents($entity, 'slotTypes');
     $sectionForm = $this->get('form.factory')->create('builder_section');
     return $this->delegateView(['viewParameters' => ['form' => $this->setFormTheme($form, 'MauticEmailBundle:Email:form.html.php', 'MauticEmailBundle:FormTheme\\Email'), 'isVariant' => $entity->isVariant(true), 'tokens' => !empty($tokens) ? $tokens['tokenSections'] : $model->getBuilderComponents($entity, 'tokenSections'), 'slots' => $this->buildSlotForms($slotTypes), 'themes' => $this->factory->getInstalledThemes('email', true), 'email' => $entity, 'forceTypeSelection' => $forceTypeSelection, 'attachmentSize' => $attachmentSize, 'builderAssets' => trim(preg_replace('/\\s+/', ' ', $this->getAssetsForBuilder())), 'sectionForm' => $sectionForm->createView()], 'contentTemplate' => 'MauticEmailBundle:Email:form.html.php', 'passthroughVars' => ['activeLink' => '#mautic_email_index', 'mauticContent' => 'email', 'updateSelect' => InputHelper::clean($this->request->query->get('updateSelect')), 'route' => $this->generateUrl('mautic_email_action', ['objectAction' => 'edit', 'objectId' => $entity->getId()])]]);
 }