Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct($options = [], Application $app = null)
 {
     $templatePaths = new TemplatePaths();
     $this->app = $app;
     $templatePaths->setTemplateRootPaths(array(base_path() . '/resources/Private/Templates/'));
     $templatePaths->setLayoutRootPaths(array(base_path() . '/resources/Private/Layouts/'));
     $templatePaths->setPartialRootPaths(array(base_path() . '/resources/Private/Partials/'));
     $this->view = new TemplateView($templatePaths);
     $context = $this->view->getRenderingContext();
     $context->setControllerName($this->determineControllerName());
     $this->view->setRenderingContext($context);
 }
 /**
  * Renders a partial.
  *
  * @param string $partialName
  * @param string $sectionName
  * @param array $variables
  * @param boolean $ignoreUnknown Ignore an unknown section and just return an empty string
  * @return string
  */
 public function renderPartial($partialName, $sectionName, array $variables, $ignoreUnknown = FALSE)
 {
     if (!isset($this->partialIdentifierCache[$partialName])) {
         $this->partialIdentifierCache[$partialName] = $this->templatePaths->getPartialIdentifier($partialName);
     }
     $partialIdentifier = $this->partialIdentifierCache[$partialName];
     $parsedPartial = $this->getOrParseAndStoreTemplate($partialIdentifier, function ($parent, TemplatePaths $paths) use($partialName) {
         return $paths->getPartialSource($partialName);
     });
     $renderingContext = clone $this->getCurrentRenderingContext();
     $renderingContext->setVariableProvider($renderingContext->getVariableProvider()->getScopeCopy($variables));
     $this->startRendering(self::RENDERING_PARTIAL, $parsedPartial, $renderingContext);
     if ($sectionName !== NULL) {
         $output = $this->renderSection($sectionName, $variables, $ignoreUnknown);
     } else {
         $output = $parsedPartial->render($renderingContext);
     }
     $this->stopRendering();
     return $output;
 }
Exemple #3
0
 /**
  * @test
  */
 public function testGetTemplateIdentifierReturnsSourceChecksumWithControllerAndActionAndFormat()
 {
     $instance = new TemplatePaths();
     $instance->setTemplateSource('foobar');
     $this->assertEquals('source_8843d7f92416211de9ebb963ff4ce28125932878_DummyController_dummyAction_html', $instance->getTemplateIdentifier('DummyController', 'dummyAction'));
 }
 /**
  * @test
  */
 public function testGetTemplateSourceThrowsExceptionIfFileNotFound()
 {
     $instance = new TemplatePaths();
     $this->setExpectedException('TYPO3Fluid\\Fluid\\View\\Exception\\InvalidTemplateResourceException');
     $instance->getTemplateSource();
 }
Exemple #5
0
 /**
  * Public API for currently protected method. Can be dropped when switching to
  * Fluid 1.1.0 or above.
  *
  * @param string $partialName
  * @return string
  */
 public function getPartialPathAndFilename($partialName)
 {
     return parent::getPartialPathAndFilename($partialName);
 }