private function sendNewsletter(NodeInterface $node, $previewEmail = NULL, $languageKey = NULL, array $languageConfiguration = NULL)
 {
     // The Receiver Group association is specified in each individual node dimension,
     // but as the user submitted it in a certain Node Dimension, we're using *exactly* this
     // $receiverGroup which the user has submitted.
     /* @var $receiverGroup \Sandstorm\Newsletter\Domain\Model\ReceiverGroup */
     $receiverGroup = $this->receiverGroupRepository->findByIdentifier($node->getProperty('receiverGroup'));
     if ($receiverGroup == NULL) {
         // TODO: log!
         return;
     }
     $context = ['workspaceName' => 'live'];
     if ($languageKey) {
         $context['dimensions'] = array('language' => $languageConfiguration['values']);
         $context['targetDimensions'] = array('language' => reset($languageConfiguration['values']));
     }
     /* @var $nodeInCorrectDimension NodeInterface */
     $nodeInCorrectDimension = (new FlowQuery(array($node)))->context($context)->get(0);
     if ($nodeInCorrectDimension == NULL) {
         // Skip un-existing nodes
         return;
     }
     $this->newsletterRenderingView->assign('value', $nodeInCorrectDimension);
     $html = $this->newsletterRenderingView->render();
     $html = $this->styleInliningService->inlineStyles($html);
     $newsletter = new Newsletter();
     $newsletterIdentifier = $node->getIdentifier();
     if ($languageKey) {
         $newsletterIdentifier .= '_' . $languageKey;
     }
     if ($previewEmail) {
         $newsletterIdentifier .= uniqid('__', true);
     }
     $newsletter->setIdentifier($newsletterIdentifier);
     $newsletter->setHtmlContent($html);
     $newsletter->setSubject($nodeInCorrectDimension->getProperty('subjectTemplate'));
     if ($previewEmail !== NULL) {
         $newsletter->setReceiverEmailTemplate($previewEmail);
         $newsletter->setReceiverGroup($receiverGroup->singlePersonReceiverGroup());
     } else {
         $newsletter->setReceiverEmailTemplate($nodeInCorrectDimension->getProperty('receiverEmailTemplate'));
         $newsletter->setReceiverGroup($receiverGroup);
     }
     $newsletter->setReceiverNameTemplate($nodeInCorrectDimension->getProperty('receiverNameTemplate'));
     $newsletter->setSenderEmailTemplate($nodeInCorrectDimension->getProperty('senderEmailTemplate'));
     $newsletter->setSenderNameTemplate($nodeInCorrectDimension->getProperty('senderNameTemplate'));
     $newsletter->setReplyToEmailTemplate($nodeInCorrectDimension->getProperty('replyToEmailTemplate'));
     $newsletter->setNewsletterLink($this->linkingService->createNodeUri($this->getControllerContext(), $nodeInCorrectDimension, NULL, NULL, TRUE));
     $unsubscribeListIdentifier = null;
     if ($receiverGroup->getUnsubscribeList()) {
         $unsubscribeListIdentifier = $this->persistenceManager->getIdentifierByObject($receiverGroup->getUnsubscribeList());
     }
     $newsletter->setUnsubscribeLink($this->uriBuilder->reset()->setCreateAbsoluteUri(TRUE)->uriFor('unsubscribe', array('unsubscribeList' => $unsubscribeListIdentifier), 'Unsubscribe', 'Sandstorm.Newsletter'));
     $this->newsletterSendingService->sendNewsletter($newsletter, $languageKey);
 }
 /**
  * Checks if the optionally given node context path, affected node context path and typoscript path are set
  * and overrides the rendering to use those. Will also add a "X-Neos-AffectedNodePath" header in case the
  * actually affected node is different from the one routing resolved.
  * This is used in out of band rendering for the backend.
  *
  * @return void
  */
 protected function overrideViewVariablesFromInternalArguments()
 {
     if (($nodeContextPath = $this->request->getInternalArgument('__nodeContextPath')) !== NULL) {
         $node = $this->propertyMapper->convert($nodeContextPath, NodeInterface::class);
         if (!$node instanceof NodeInterface) {
             throw new NodeNotFoundException(sprintf('The node with context path "%s" could not be resolved', $nodeContextPath), 1437051934);
         }
         $this->view->assign('value', $node);
     }
     if (($affectedNodeContextPath = $this->request->getInternalArgument('__affectedNodeContextPath')) !== NULL) {
         $this->response->setHeader('X-Neos-AffectedNodePath', $affectedNodeContextPath);
     }
     if (($typoScriptPath = $this->request->getInternalArgument('__typoScriptPath')) !== NULL) {
         $this->view->setTypoScriptPath($typoScriptPath);
     }
 }
 /**
  * Render the node
  *
  * @return string
  */
 protected function renderContent(ControllerContext $controllerContext)
 {
     $this->contentCache->flushByTag(sprintf('Node_%s', $this->getNode()->getParent()->getIdentifier()));
     $parentDomAddress = $this->getParentDomAddress();
     $fusionView = new FusionView();
     $fusionView->setControllerContext($controllerContext);
     $fusionView->assign('value', $this->getNode()->getParent());
     $fusionView->setTypoScriptPath($parentDomAddress->getFusionPath());
     return $fusionView->render();
 }