Helpful if you want to use Fluid separately from MVC E.g. to generate template based emails.
Inheritance: extends AbstractTemplateView
 /**
  * @test
  * @expectedException \Neos\FluidAdaptor\View\Exception\InvalidTemplateResourceException
  */
 public function getPartialPathAndFilenameThrowsExceptionIfPartialFileIsADirectory()
 {
     vfsStreamWrapper::register();
     mkdir('vfs://MyPartials/NotAFile');
     $this->standaloneView->setPartialRootPath('vfs://MyPartials');
     $this->standaloneView->getTemplatePaths()->getPartialSource('NotAFile');
 }
 /**
  * Prepare a Fluid view for rendering an error page with the Neos backend
  *
  * @return StandaloneView
  */
 protected function prepareFluidView()
 {
     $fluidView = new StandaloneView();
     $fluidView->setControllerContext($this->runtime->getControllerContext());
     $fluidView->setFormat('html');
     $fluidView->setTemplatePathAndFilename('resource://Neos.Neos/Private/Templates/Error/NeosBackendMessage.html');
     $fluidView->setLayoutRootPath('resource://Neos.Neos/Private/Layouts/');
     // FIXME find a better way than using templates as partials
     $fluidView->setPartialRootPath('resource://Neos.Neos/Private/Templates/TypoScriptObjects/');
     return $fluidView;
 }
 /**
  * Sends an activation mail for $token to the given $recipientAddress.
  *
  * The mail is built and sent according to the configuration given in the preset assigned to the $token.
  *
  * @param string $recipientAddress
  * @param Token $token
  * @param array $additionalTemplateVariables
  * @return int
  */
 public function sendActivationMail($recipientAddress, Token $token, array $additionalTemplateVariables = [])
 {
     $preset = $token->getPreset();
     $activationLink = $this->getActivationLink($token);
     $mail = new Message();
     $mail->setFrom([$preset['mail']['from']['address'] => $preset['mail']['from']['name']])->setTo($recipientAddress)->setSubject($preset['mail']['subject']);
     $templateVariables = array_merge(['activationLink' => $activationLink, 'recipientAddress' => $recipientAddress, 'token' => $token, 'meta' => $token->getMeta()], $additionalTemplateVariables);
     $this->fluidView->setTemplatePathAndFilename($preset['mail']['message']['plaintext']);
     $this->fluidView->assignMultiple($templateVariables);
     $mail->setBody($this->fluidView->render(), 'text/plain');
     if (isset($preset['mail']['html'])) {
         $this->fluidView->setTemplatePathAndFilename($preset['mail']['message']['html']);
         $this->fluidView->assignMultiple($templateVariables);
         $mail->setBody($this->fluidView->render(), 'text/html');
     }
     return $mail->send();
 }
 /**
  * @param NodeInterface $node
  * @return string
  * @throws NeosException
  */
 public function render(NodeInterface $node)
 {
     if ($this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess') === false) {
         return '';
     }
     /** @var $actionRequest ActionRequest */
     $actionRequest = $this->controllerContext->getRequest();
     $innerView = new StandaloneView($actionRequest);
     $innerView->setTemplatePathAndFilename('resource://Neos.Neos/Private/Templates/Backend/Content/Container.html');
     $innerView->setFormat('html');
     $innerView->setPartialRootPath('resource://Neos.Neos/Private/Partials');
     $user = $this->partyService->getAssignedPartyOfAccount($this->securityContext->getAccount());
     $innerView->assignMultiple(array('node' => $node, 'modules' => $this->menuHelper->buildModuleList($this->controllerContext), 'sites' => $this->menuHelper->buildSiteList($this->controllerContext), 'user' => $user));
     return $innerView->render();
 }
 /**
  * Render the given template file with the given variables
  *
  * @param string $templatePathAndFilename
  * @param array $contextVariables
  * @return string
  * @throws \Neos\FluidAdaptor\Core\Exception
  */
 protected function renderTemplate($templatePathAndFilename, array $contextVariables)
 {
     $standaloneView = new StandaloneView();
     $standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
     $standaloneView->assignMultiple($contextVariables);
     return $standaloneView->render();
 }
Exemple #6
0
 /**
  * @return StandaloneView
  * @throws FinisherException
  */
 protected function initializeStandaloneView()
 {
     $standaloneView = new StandaloneView();
     if (!isset($this->options['templatePathAndFilename'])) {
         throw new FinisherException('The option "templatePathAndFilename" must be set for the EmailFinisher.', 1327058829);
     }
     $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']);
     if (isset($this->options['partialRootPath'])) {
         $standaloneView->setPartialRootPath($this->options['partialRootPath']);
     }
     if (isset($this->options['layoutRootPath'])) {
         $standaloneView->setLayoutRootPath($this->options['layoutRootPath']);
     }
     if (isset($this->options['variables'])) {
         $standaloneView->assignMultiple($this->options['variables']);
     }
     return $standaloneView;
 }
 /**
  * @param AbstractTypoScriptObject $typoScriptObject
  * @param ActionRequest $request The current action request. If none is specified it will be created from the environment.
  */
 public function __construct(AbstractTypoScriptObject $typoScriptObject, ActionRequest $request = null)
 {
     parent::__construct($request);
     $this->typoScriptObject = $typoScriptObject;
 }
 protected function createIdentifierForFile($pathAndFilename, $prefix)
 {
     $prefix = $this->fileIdentifierPrefix . $prefix;
     return parent::createIdentifierForFile($pathAndFilename, $prefix);
 }