Controller/AzineEmailTemplateController.php
public function webViewAction(Request $request, $token)
    {
        // find email recipients, template & params
        $sentEmail = $this->getSentEmailForToken($token);

        // check if the sent email is available
        if (null !== $sentEmail) {
            // check if the current user is allowed to see the email
            if ($this->userIsAllowedToSeeThisMail($sentEmail)) {
                $template = $sentEmail->getTemplate();
                $emailVars = $sentEmail->getVariables();

                // re-attach all entities to the EntityManager.
                $this->reAttachAllEntities($emailVars);

                // remove the web-view-token from the param-array
                $templateProvider = $this->getTemplateProviderService();
                unset($emailVars[$templateProvider->getWebViewTokenId()]);

                // render & return email
                $response = $this->renderResponse("$template.html.twig", $emailVars);

                $campaignParams = $templateProvider->getCampaignParamsFor($template, $emailVars);

                if (null != $campaignParams && sizeof($campaignParams) > 0) {
                    $response->setContent($this->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($response->getContent(), $campaignParams));
                }

                return $response;

                // if the user is not allowed to see this mail
            }
            $msg = $this->get('translator')->trans('web.pre.view.test.mail.access.denied');
            throw new AccessDeniedException($msg);
        }

        // the parameters-array is null => the email is not available in webView
        $days = $this->getParameter('azine_email_web_view_retention');
        $response = $this->renderResponse('AzineEmailBundle:Webview:mail.not.available.html.twig', array('days' => $days));
        $response->setStatusCode(404);

        return $response;
    }
public function webViewAction(Request $request, $token)
    {
        // find email recipients, template & params
        $sentEmail = $this->getSentEmailForToken($token);

        // check if the sent email is available
        if (null !== $sentEmail) {
            // check if the current user is allowed to see the email
            if ($this->userIsAllowedToSeeThisMail($sentEmail)) {
                $template = $sentEmail->getTemplate();
                $emailVars = $sentEmail->getVariables();

                // re-attach all entities to the EntityManager.
                $this->reAttachAllEntities($emailVars);

                // remove the web-view-token from the param-array
                $templateProvider = $this->getTemplateProviderService();
                unset($emailVars[$templateProvider->getWebViewTokenId()]);

                // render & return email
                $response = $this->renderResponse("$template.html.twig", $emailVars);

                $campaignParams = $templateProvider->getCampaignParamsFor($template, $emailVars);

                if (null != $campaignParams && sizeof($campaignParams) > 0) {
                    $response->setContent($this->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($response->getContent(), $campaignParams));
                }

                return $response;

                // if the user is not allowed to see this mail
            }
            $msg = $this->get('translator')->trans('web.pre.view.test.mail.access.denied');
            throw new AccessDeniedException($msg);
        }

        // the parameters-array is null => the email is not available in webView
        $days = $this->getParameter('azine_email_web_view_retention');
        $response = $this->renderResponse('AzineEmailBundle:Webview:mail.not.available.html.twig', array('days' => $days));
        $response->setStatusCode(404);

        return $response;
    }
public function webViewAction ( Request $ request , $ token ) { // find email recipients, template & params $ sentEmail = $ this -> getSentEmailForToken ( $ token ) ; // check if the sent email is available if ( null !== $ sentEmail ) { // check if the current user is allowed to see the email if ( $ this -> userIsAllowedToSeeThisMail ( $ sentEmail ) ) { $ template = $ sentEmail -> getTemplate ( ) ; $ emailVars = $ sentEmail -> getVariables ( ) ; // re-attach all entities to the EntityManager. $ this -> reAttachAllEntities ( $ emailVars ) ; // remove the web-view-token from the param-array $ templateProvider = $ this -> getTemplateProviderService ( ) ; unset ( $ emailVars [ $ templateProvider -> getWebViewTokenId ( ) ] ) ; // render & return email $ response = $ this -> renderResponse ( "$template.html.twig" , $ emailVars ) ; $ campaignParams = $ templateProvider -> getCampaignParamsFor ( $ template , $ emailVars ) ; if ( null != $ campaignParams && sizeof ( $ campaignParams ) > 0 ) { $ response -> setContent ( $ this -> get ( 'azine.email.bundle.twig.filters' ) -> addCampaignParamsToAllUrls ( $ response -> getContent ( ) , $ campaignParams ) ) ; } return $ response ; // if the user is not allowed to see this mail } $ msg = $ this -> get ( 'translator' ) -> trans ( 'web.pre.view.test.mail.access.denied' ) ; throw new AccessDeniedException ( $ msg ) ; } // the parameters-array is null => the email is not available in webView $ days = $ this -> getParameter ( 'azine_email_web_view_retention' ) ; $ response = $ this -> renderResponse ( 'AzineEmailBundle:Webview:mail.not.available.html.twig' , array ( 'days' => $ days ) ) ; $ response -> setStatusCode ( 404 ) ; return $ response ; }
Show a web-version of an email that has been sent to recipients and has been stored in the database.

@param Request $request
@param string  $token

@return Response
Show a web - version of an email that has been sent to recipients and has been stored in the database .