TYPO3 CMS  TYPO3_7-6
AbstractCompiledTemplate.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
19 {
24 
25  // These tokens are replaced by the Backporter for implementing different behavior in TYPO3 v4
29  protected static $objectContainer;
30 
34  protected static $defaultEncoding = null;
35 
45  public function getViewHelper($uniqueCounter, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext, $viewHelperName)
46  {
47  if (self::$objectContainer === null) {
48  self::$objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
49  }
50  if (isset($this->viewHelpersByPositionAndContext[$uniqueCounter])) {
51  if ($this->viewHelpersByPositionAndContext[$uniqueCounter]->contains($renderingContext)) {
52  $viewHelper = $this->viewHelpersByPositionAndContext[$uniqueCounter][$renderingContext];
53  $viewHelper->resetState();
54  return $viewHelper;
55  } else {
56  $viewHelperInstance = self::$objectContainer->getInstance($viewHelperName);
57  if ($viewHelperInstance instanceof \TYPO3\CMS\Core\SingletonInterface) {
58  $viewHelperInstance->resetState();
59  }
60  $this->viewHelpersByPositionAndContext[$uniqueCounter]->attach($renderingContext, $viewHelperInstance);
61  return $viewHelperInstance;
62  }
63  } else {
64  $this->viewHelpersByPositionAndContext[$uniqueCounter] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class);
65  $viewHelperInstance = self::$objectContainer->getInstance($viewHelperName);
66  if ($viewHelperInstance instanceof \TYPO3\CMS\Core\SingletonInterface) {
67  $viewHelperInstance->resetState();
68  }
69  $this->viewHelpersByPositionAndContext[$uniqueCounter]->attach($renderingContext, $viewHelperInstance);
70  return $viewHelperInstance;
71  }
72  }
73 
77  public function isCompilable()
78  {
79  return false;
80  }
81 
85  public function isCompiled()
86  {
87  return true;
88  }
89 
94  public static function resolveDefaultEncoding()
95  {
96  if (static::$defaultEncoding === null) {
97  static::$defaultEncoding = 'UTF-8';
98  }
99  return static::$defaultEncoding;
100  }
101 }
getViewHelper($uniqueCounter, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext, $viewHelperName)