예제 #1
0
 public function __construct(\TYPO3Fluid\Fluid\View\TemplateView $fluid, FileLocatorInterface $locator, ContainerInterface $container)
 {
     $this->fluid = $fluid;
     $this->locator = $locator;
     $this->container = $container;
     $fluid->setRenderingContext($container->get('fluid.renderingContext'));
     $this->fluid->getRenderingContext()->setTemplatePaths(new SymfonyTemplatePaths());
     $this->fluid->getRenderingContext()->setContainer($container);
 }
예제 #2
0
 /**
  * If your test case requires a custom View instance
  * return the instance from this method.
  *
  * @return ViewInterface
  */
 protected function getView($withCache = FALSE)
 {
     $view = new TemplateView();
     $cache = $this->getCache();
     if ($cache && $withCache) {
         $view->getRenderingContext()->setCache($cache);
     }
     return $view;
 }
예제 #3
0
 public function createView()
 {
     $view = new TemplateView();
     $paths = new \TYPO3Fluid\Docs\Fluid\TemplatePaths();
     $view->getRenderingContext()->setTemplatePaths($paths);
     $paths->setLayoutRootPaths(array(__DIR__ . '/../Layouts/'));
     $paths->setPartialRootPaths(array(__DIR__ . '/../Partials/'));
     $view->getRenderingContext()->getViewHelperResolver()->addNamespace('d', 'TYPO3Fluid\\Docs\\ViewHelpers');
     $view->getRenderingContext()->setTemplateProcessors(array(new \TYPO3Fluid\Docs\TemplateProcessor\CodeTemplateProcessor()));
     return $view;
 }
예제 #4
0
 /**
  * If your test case requires a custom View instance
  * return the instance from this method.
  *
  * @return ViewInterface
  */
 protected function getView($withCache = FALSE)
 {
     $paths = $this->getTemplatePaths();
     $context = $this->getRenderingContext();
     $resolver = $this->getViewHelperResolver();
     if (!$withCache) {
         $view = new TemplateView($paths, $context);
     } else {
         $cache = $this->getCache();
         $view = new TemplateView($paths, $context, $cache);
     }
     $view->setViewHelperResolver($resolver);
     return $view;
 }
예제 #5
0
 /**
  * @test
  */
 public function testRenderSupportsContentAs()
 {
     $variables = array('foo' => 'bar', 'foobar' => 'tagcontent-foobar');
     $this->view->expects($this->once())->method('renderPartial')->with('test1', 'test2', $variables, TRUE)->willReturn('baz');
     $this->subject->expects($this->any())->method('renderChildren')->willReturn('tagcontent-foobar');
     $this->subject->setArguments(array('partial' => 'test1', 'section' => 'test2', 'delegate' => NULL, 'arguments' => array('foo' => 'bar'), 'optional' => TRUE, 'default' => NULL, 'contentAs' => 'foobar'));
     $output = $this->subject->render();
     $this->assertEquals('baz', $output);
 }
예제 #6
0
 public function render($template, $variables = array())
 {
     $paths = new \TYPO3Fluid\Fluid\View\TemplatePaths();
     // $paths->setTemplateRootPaths(array(__DIR__ . '/../Templates/'));
     $paths->setLayoutRootPaths(array(BASE_DIRECTORY . '/../Resources/Layouts/'));
     $paths->setPartialRootPaths(array(BASE_DIRECTORY . '/../Resources/Partials/'));
     $parts = explode('/', $template);
     array_walk($parts, function (&$value, $key) {
         $value = ucfirst($value);
     });
     $path = implode('/', $parts);
     $templateFile = BASE_DIRECTORY . '/../Resources/Templates/' . $path . '.html';
     $paths->setTemplatePathAndFilename($templateFile);
     $view = new TemplateView($paths);
     $view->assignMultiple($variables);
     $view->getViewHelperResolver()->registerNamespace('s', 'Famelo\\Soup\\ViewHelpers');
     echo $view->render();
 }
예제 #7
0
 /**
  * Renders the view and returns the content
  *
  * @param string $title The title to be shown
  * @param string $message The message to be shown
  * @param int $severity The severity of the error, see AbstractMessage constants
  * @param int $errorCode The error code to be referenced
  * @return string the output of the view
  */
 public function errorAction(string $title, string $message, int $severity = AbstractMessage::ERROR, int $errorCode = 0) : string
 {
     $this->severity = $severity;
     $classes = [AbstractMessage::NOTICE => 'notice', AbstractMessage::INFO => 'information', AbstractMessage::OK => 'ok', AbstractMessage::WARNING => 'warning', AbstractMessage::ERROR => 'error'];
     $this->view->assign('severityCssClass', $classes[$this->severity]);
     $this->view->assign('severity', $this->severity);
     $this->view->assign('message', $message);
     $this->view->assign('title', $title);
     $this->view->assign('errorCodeUrlPrefix', TYPO3_URL_EXCEPTION);
     $this->view->assign('errorCode', $errorCode);
     $this->view->assign('logo', PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::extPath('backend', 'Resources/Public/Images/typo3_orange.svg')));
     $this->view->assign('cssFile', PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::extPath('core', 'Resources/Public/Css/errorpage.css')));
     $this->view->assign('copyrightYear', TYPO3_copyright_year);
     return $this->view->render('Error');
 }
예제 #8
0
 public function render($template)
 {
     $this->view->getTemplatePaths()->setTemplatePathAndFilename(ROOT_PATH . '/Templates/' . $template . '.html');
     echo $this->view->render();
 }