‪TYPO3CMS  11.5
RenderingContextFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Container\ContainerInterface;
25 use TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface;
26 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\EscapingModifierTemplateProcessor;
27 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\NamespaceDetectionTemplateProcessor;
28 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\PassthroughSourceModifierTemplateProcessor;
29 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessorInterface;
30 
51 {
52  private ContainerInterface ‪$container;
55 
56  public function ‪__construct(
57  ContainerInterface ‪$container,
60  ) {
61  $this->container = ‪$container;
62  $this->cacheManager = ‪$cacheManager;
63  $this->viewHelperResolverFactory = ‪$viewHelperResolverFactory;
64  }
65 
66  public function ‪create(): ‪RenderingContext
67  {
69  $processors = [];
70 
71  if ($this->container instanceof ‪FailsafeContainer) {
72  // Load default set of processors in failsafe mode (install tool context)
73  // as custom processors can not be retrieved from the symfony container
74  $processors = [
75  new EscapingModifierTemplateProcessor(),
76  new PassthroughSourceModifierTemplateProcessor(),
77  new NamespaceDetectionTemplateProcessor(),
78  ];
79  } else {
80  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['preProcessors'] as $className) {
81  if ($this->container->has($className)) {
83  $processors[] = $this->container->get($className);
84  } else {
85  // @deprecated since v11, will be removed with 12.
86  // Layer for processors that can't be instantiated by symfony-DI yet,
87  // probably due to a missing Services.yaml in the providing extension. Fall back to ObjectManager,
88  // which logs a deprecation. If condition and else can be dropped in v12.
89  $objectManager = $this->container->get(ObjectManager::class);
91  $processors[] = $objectManager->get($className);
92  }
93  }
94  }
95 
96  $cache = $this->cacheManager->getCache('fluid_template');
97  if (!$cache instanceof FluidCacheInterface) {
98  throw new \RuntimeException('Cache fluid_template must implement FluidCacheInterface', 1623148753);
99  }
100 
101  return new ‪RenderingContext(
102  $this->viewHelperResolverFactory->create(),
103  $cache,
104  $processors,
105  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['expressionNodeTypes']
106  );
107  }
108 }
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory\$viewHelperResolverFactory
‪ViewHelperResolverFactoryInterface $viewHelperResolverFactory
Definition: RenderingContextFactory.php:54
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory\$container
‪ContainerInterface $container
Definition: RenderingContextFactory.php:52
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory\$cacheManager
‪CacheManager $cacheManager
Definition: RenderingContextFactory.php:53
‪TYPO3\CMS\Core\DependencyInjection\FailsafeContainer
Definition: FailsafeContainer.php:26
‪TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolverFactoryInterface
Definition: ViewHelperResolverFactoryInterface.php:27
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory\create
‪create()
Definition: RenderingContextFactory.php:66
‪TYPO3\CMS\Fluid\Core\Rendering
Definition: RenderingContext.php:16
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory
Definition: RenderingContextFactory.php:51
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory\__construct
‪__construct(ContainerInterface $container, CacheManager $cacheManager, ViewHelperResolverFactoryInterface $viewHelperResolverFactory)
Definition: RenderingContextFactory.php:56
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
Definition: RenderingContext.php:37
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:31