/** * Overrides the standard resolveView method * * @return ViewInterface $view The view */ protected function resolveView() { $view = new TemplateView(); $view->setControllerContext($this->controllerContext); $view->setTemplatePathAndFilename(FLOW_PATH_FLOW . 'Resources/Private/Mvc/StandardView_Template.html'); return $view; }
/** * Renders a Fluid template and tried to put it into a pdf * * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object * @return string PDF Raw Data * @api */ public function render($actionName = NULL) { $this->controllerContext->getResponse()->setHeader('Content-Type', 'application/pdf'); $htmlFromFluid = parent::render($actionName); $pdf = new \TYPO3\TcPdf\Pdf($this->settings['pageFormat'], $this->settings['sizeUnit'], $this->settings['pageOrientation'], TRUE, 'UTF-8', TRUE); $pdf->SetFont($this->settings['font']['family'], $this->settings['font']['style'], $this->settings['font']['size']); $pdf->AddPage(); $pdf->writeHTML($htmlFromFluid, true, false, false, false, ''); return $pdf->Output('', 'S'); }
protected function load($name) { $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name))); if (false !== strpos($name, '..')) { throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); } if (!preg_match('/^([^:]*):([^:]*):(.+)\\.([^\\.]+)\\.*([^\\.]*)$/', $name, $matches)) { return false; } $bundle = $this->container->get('kernel')->getBundle($matches[1]); $bundlePaths = array($bundle->getPath()); if ($bundle instanceof AppBundle) { $bundlePaths[] = $bundle->getPath(); } $this->fluid->getRenderingContext()->getTemplatePaths()->fillDefaultsByBundlePaths($bundlePaths); return $this->fluid->getRenderingContext()->getTemplatePaths()->resolveTemplateFileForControllerAndActionAndFormat($matches[2], $matches[3]); }
/** * @test */ public function getTemplateRootPathsReturnsUserSpecifiedTemplatePaths() { $templateView = new TemplateView(); $templateRootPaths = array('/foo/bar', 'baz'); $templateView->setOption('templateRootPaths', $templateRootPaths); $actual = $templateView->getTemplateRootPaths(); $this->assertEquals($templateRootPaths, $actual, 'A set template root path was not returned correctly.'); }
/** * Renders a template. * * @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance * @param array $parameters An array of parameters to pass to the template * * @return string The evaluated template as a string * * @throws \RuntimeException if the template cannot be rendered * * @api */ public function render($name, array $parameters = array()) { $this->fluid->setTemplatePathAndFilename($this->load($name)); $this->fluid->assignMultiple($parameters); return $this->fluid->render(); }
protected function getPartialRootPaths() { $partialRootPaths = parent::getPartialRootPaths(); $partialRootPaths[] = 'resource://Sandstorm.CrudForms/Private/Partials/'; return $partialRootPaths; }