TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:15 +02:00
commit 6830982e7d
295 changed files with 31995 additions and 0 deletions
@@ -0,0 +1,78 @@
<?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\Extbase\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use TYPO3\CMS\Extbase\Attribute\Authorize;
use TYPO3\CMS\Extbase\Mvc\Controller\AuthorizeRegistry;
/**
* Scans all extbase action controllers for #[Authorize] attributes
* and registers their configurations in the {@see AuthorizeRegistry}.
*
* @internal
*/
final readonly class AuthorizePass implements CompilerPassInterface
{
public function __construct(private string $tagName) {}
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition(AuthorizeRegistry::class)) {
return;
}
$registryDefinition = $container->findDefinition(AuthorizeRegistry::class);
foreach ($container->findTaggedServiceIds($this->tagName) as $serviceName => $tags) {
$definition = $container->findDefinition($serviceName);
if ($definition->isAbstract()) {
continue;
}
$className = $definition->getClass() ?? $serviceName;
$reflectionClass = $container->getReflectionClass($className);
if ($reflectionClass === null) {
continue;
}
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (!str_ends_with($method->getName(), 'Action')) {
continue;
}
$attributes = $method->getAttributes(Authorize::class);
if ($attributes === []) {
continue;
}
foreach ($attributes as $attribute) {
$authorize = $attribute->newInstance();
$registryDefinition->addMethodCall('add', [
$className,
$method->getName(),
$authorize->callback,
$authorize->requireLogin,
$authorize->requireGroups,
]);
}
}
}
}
}
@@ -0,0 +1,77 @@
<?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\Extbase\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use TYPO3\CMS\Extbase\Attribute\RateLimit;
use TYPO3\CMS\Extbase\Mvc\Controller\RateLimitRegistry;
/**
* Scans all extbase action controllers for #[RateLimit] attributes
* and registers their configurations in the {@see RateLimitRegistry}.
*
* @internal
*/
final readonly class RateLimitPass implements CompilerPassInterface
{
public function __construct(private string $tagName) {}
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition(RateLimitRegistry::class)) {
return;
}
$registryDefinition = $container->findDefinition(RateLimitRegistry::class);
foreach ($container->findTaggedServiceIds($this->tagName) as $serviceName => $tags) {
$definition = $container->findDefinition($serviceName);
if ($definition->isAbstract()) {
continue;
}
$className = $definition->getClass() ?? $serviceName;
$reflectionClass = $container->getReflectionClass($className);
if ($reflectionClass === null) {
continue;
}
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (!str_ends_with($method->getName(), 'Action')) {
continue;
}
$attributes = $method->getAttributes(RateLimit::class);
if ($attributes === []) {
continue;
}
$rateLimit = $attributes[0]->newInstance();
$registryDefinition->addMethodCall('add', [
$className,
$method->getName(),
$rateLimit->limit,
$rateLimit->interval,
$rateLimit->policy,
$rateLimit->message,
]);
}
}
}
}
@@ -0,0 +1,97 @@
<?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\Extbase\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Property\Exception\InvalidTypeConverterConfigurationException;
use TYPO3\CMS\Extbase\Property\TypeConverterRegistry;
/**
* Find all TypeConverters for Extbase's Property Mapper.
*
* @internal
*/
final class TypeConverterPass implements CompilerPassInterface
{
private string $tagName;
public function __construct(string $tagName)
{
$this->tagName = $tagName;
}
/**
* @throws InvalidTypeConverterConfigurationException
*/
public function process(ContainerBuilder $container): void
{
$typeConverterRegistryDefinition = $container->findDefinition(TypeConverterRegistry::class);
foreach ($container->findTaggedServiceIds($this->tagName) as $serviceName => $tags) {
$definition = $container->findDefinition($serviceName);
if (!$definition->isAutoconfigured() || $definition->isAbstract()) {
continue;
}
$definition->setPublic(true);
foreach ($tags as $attributes) {
if (!isset($attributes['sources'])) {
throw new InvalidTypeConverterConfigurationException(
sprintf(
'Configuration for TypeConverter "%s" misses the "sources" attribute.',
$serviceName
),
1638376684
);
}
$sources = GeneralUtility::trimExplode(',', (string)$attributes['sources'], true);
if ($sources === []) {
throw new InvalidTypeConverterConfigurationException(
sprintf(
'The sources attribute of the configuration of TypeConverter "%s" contains an empty list.',
$serviceName
),
1638376687
);
}
if (!($attributes['target'] ?? false)) {
throw new InvalidTypeConverterConfigurationException(
sprintf(
'Configuration for TypeConverter "%s" misses a valid "target" attribute.',
$serviceName
),
1638376689
);
}
$typeConverterRegistryDefinition->addMethodCall('add', [
$definition,
(int)($attributes['priority'] ?? 10),
$sources,
$attributes['target'],
]);
}
}
}
}