TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:20 +02:00
commit c7a46689ff
115 changed files with 11736 additions and 0 deletions
+120
View File
@@ -0,0 +1,120 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Fluid\Core\Rendering;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver;
use TYPO3\CMS\Fluid\View\TemplatePaths;
use TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface;
use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
use TYPO3Fluid\Fluid\Core\Parser\Configuration;
use TYPO3Fluid\Fluid\Core\Parser\InterceptorInterface;
use TYPO3Fluid\Fluid\Core\Parser\TemplateParser;
use TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider;
use TYPO3Fluid\Fluid\Core\ViewHelper\ArgumentProcessorInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker;
use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
{
/**
* @var string
*/
protected $controllerName = 'Default';
/**
* @var string
*/
protected $controllerAction = 'Default';
/**
* @internal constructor, use `RenderingContextFactory->create()` instead
*/
public function __construct(
ViewHelperResolver $viewHelperResolver,
FluidCacheInterface $cache,
array $templateProcessors,
array $expressionNodeTypes,
TemplatePaths $templatePaths,
ArgumentProcessorInterface $argumentProcessor
) {
// Partially cloning parent::__construct() but with custom implementations.
$this->setTemplateParser(new TemplateParser());
$this->setTemplateCompiler(new TemplateCompiler());
$this->setViewHelperInvoker(new ViewHelperInvoker());
$this->setArgumentProcessor($argumentProcessor);
$this->setViewHelperVariableContainer(new ViewHelperVariableContainer());
$this->setVariableProvider(new StandardVariableProvider());
$this->setTemplateProcessors($templateProcessors);
$this->setExpressionNodeTypes($expressionNodeTypes);
$this->setTemplatePaths($templatePaths);
$this->setViewHelperResolver($viewHelperResolver);
$this->setCache($cache);
}
/**
* Build parser configuration. Adds custom fluid interceptors from configuration.
*
* @throws \InvalidArgumentException if a class not implementing InterceptorInterface was registered
*/
public function buildParserConfiguration(): Configuration
{
$parserConfiguration = parent::buildParserConfiguration();
foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['interceptors'] as $className) {
$interceptor = GeneralUtility::makeInstance($className);
if (!$interceptor instanceof InterceptorInterface) {
throw new \InvalidArgumentException(
'Interceptor "' . $className . '" needs to implement ' . InterceptorInterface::class . '.',
1462869795
);
}
$parserConfiguration->addInterceptor($interceptor);
}
return $parserConfiguration;
}
/**
* @param string $action
*/
public function setControllerAction($action): void
{
$dotPosition = strpos($action, '.');
if ($dotPosition !== false) {
$action = substr($action, 0, $dotPosition);
}
$this->controllerAction = $action;
}
/**
* @param string $controllerName
*/
public function setControllerName($controllerName): void
{
$this->controllerName = $controllerName;
}
public function getControllerName(): string
{
return $this->controllerName;
}
public function getControllerAction(): string
{
return $this->controllerAction;
}
}
@@ -0,0 +1,112 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Fluid\Core\Rendering;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\DependencyInjection\FailsafeContainer;
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolverFactoryInterface;
use TYPO3\CMS\Fluid\View\TemplatePaths;
use TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\EscapingModifierTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\NamespaceDetectionTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\PassthroughSourceModifierTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\RemoveCommentsTemplateProcessor;
use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessorInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\ArgumentProcessorInterface;
/**
* Factory class registered in ServiceProvider to create a RenderingContext.
*
* This is a low level factory always registered, even in failsafe mode: fluid
* is needed in install tool which does not rely on the normal (cached) symfony DI
* mechanism - Services.yaml is ignored in failsafe mode.
*
* A casual failsafe instantiation / injection using ServiceProvider.php wouldn't
* need this factory. But the failsafe mechanism is strict and relies on two
* things: The service is public: true, this is the case with RenderingContext.
* And the service is shared: true - a stateless singleton. This is not true for
* RenderingContext, it by definition relies on context and must be created a-new
* per fluid parsing instance.
*
* To allow creating RenderingContext objects in failsafe mode, this factory
* is registered as service provider to dynamically prepare instances.
*
* @internal May change / vanish any time
*/
final readonly class RenderingContextFactory
{
public function __construct(
private ContainerInterface $container,
private CacheManager $cacheManager,
private ViewHelperResolverFactoryInterface $viewHelperResolverFactory,
private ArgumentProcessorInterface $argumentProcessor,
) {}
public function create(array $templatePathsArray = [], ?ServerRequestInterface $request = null): RenderingContext
{
/** @var TemplateProcessorInterface[] $processors */
$processors = [];
if ($this->container instanceof FailsafeContainer) {
// Load default set of processors in failsafe mode (install tool context)
// as custom processors can not be retrieved from the symfony container
$processors = [
new EscapingModifierTemplateProcessor(),
new PassthroughSourceModifierTemplateProcessor(),
new NamespaceDetectionTemplateProcessor(),
new RemoveCommentsTemplateProcessor(),
];
} else {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['preProcessors'] as $className) {
/** @var TemplateProcessorInterface[] $processors */
$processors[] = $this->container->get($className);
}
}
$cache = $this->cacheManager->getCache('fluid_template');
if (!$cache instanceof FluidCacheInterface) {
throw new \RuntimeException('Cache fluid_template must implement FluidCacheInterface', 1623148753);
}
$templatePaths = new TemplatePaths();
if (!empty($templatePathsArray['templateRootPaths'])) {
$templatePaths->setTemplateRootPaths($templatePathsArray['templateRootPaths']);
}
if (!empty($templatePathsArray['layoutRootPaths'])) {
$templatePaths->setLayoutRootPaths($templatePathsArray['layoutRootPaths']);
}
if (!empty($templatePathsArray['partialRootPaths'])) {
$templatePaths->setPartialRootPaths($templatePathsArray['partialRootPaths']);
}
$renderingContext = new RenderingContext(
$this->viewHelperResolverFactory->create(),
$cache,
$processors,
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['expressionNodeTypes'],
$templatePaths,
$this->argumentProcessor,
);
if ($request) {
$renderingContext->setAttribute(ServerRequestInterface::class, $request);
}
return $renderingContext;
}
}