TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:24 +02:00
commit aad9daaefd
1506 changed files with 94005 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
<?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\Form\Domain\DTO;
/**
* FormData - Complete form definition DTO
* Used for read/write operations with full form structure
*
* @internal
*/
final readonly class FormData
{
public function __construct(
public string $identifier,
public string $type,
public string $name,
public string $prototypeName,
public array $renderingOptions,
public array $finishers,
public array $renderables,
public array $variants,
) {}
public static function fromArray(array $data): self
{
return new self(
identifier: $data['identifier'] ?? '',
type: $data['type'] ?? 'Form',
name: $data['label'] ?? $data['identifier'] ?? '',
prototypeName: $data['prototypeName'] ?? 'standard',
renderingOptions: $data['renderingOptions'] ?? [],
finishers: $data['finishers'] ?? [],
renderables: $data['renderables'] ?? [],
variants: $data['variants'] ?? [],
);
}
public function toArray(): array
{
return [
'identifier' => $this->identifier,
'type' => $this->type,
'label' => $this->name,
'prototypeName' => $this->prototypeName,
'renderingOptions' => $this->renderingOptions,
'finishers' => $this->finishers,
'renderables' => $this->renderables,
'variants' => $this->variants,
];
}
}
+208
View File
@@ -0,0 +1,208 @@
<?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\Form\Domain\DTO;
/**
* FormMetadata - Lightweight DTO for form listings
* Contains only metadata, not the full form definition
*
* @internal
*/
final readonly class FormMetadata
{
public function __construct(
public string $identifier,
public string $type,
public string $name,
public string $prototypeName,
public ?string $persistenceIdentifier = null,
public bool $invalid = false,
public bool $readOnly = false,
public bool $removable = true,
public ?string $storageType = null,
public bool $duplicateIdentifier = false,
public ?int $fileUid = null,
public int $referenceCount = 0,
public ?string $editUrl = null,
public ?string $storageLocation = null,
public array $actions = [],
) {}
public static function fromArray(array $data): self
{
return new self(
identifier: $data['identifier'] ?? '',
type: $data['type'] ?? 'Form',
name: $data['label'] ?? $data['identifier'] ?? '',
prototypeName: $data['prototypeName'] ?? 'standard',
persistenceIdentifier: $data['persistenceIdentifier'] ?? null,
invalid: $data['invalid'] ?? false,
readOnly: $data['readOnly'] ?? false,
removable: $data['removable'] ?? true,
storageType: $data['storageType'] ?? null,
duplicateIdentifier: $data['duplicateIdentifier'] ?? false,
fileUid: $data['fileUid'] ?? null,
referenceCount: $data['referenceCount'] ?? 0,
editUrl: $data['editUrl'] ?? null,
storageLocation: $data['storageLocation'] ?? null,
actions: $data['actions'] ?? [],
);
}
public static function createInvalid(
string $persistenceIdentifier,
string $errorMessage
): self {
return new self(
identifier: $persistenceIdentifier,
type: 'Form',
name: $errorMessage,
prototypeName: 'standard',
persistenceIdentifier: $persistenceIdentifier,
invalid: true,
);
}
public static function createFromYaml(
array $yamlData,
string $persistenceIdentifier,
?int $fileUid = null
): self {
return self::fromArray($yamlData)
->withPersistenceIdentifier($persistenceIdentifier)
->withFileUid($fileUid);
}
public function toArray(): array
{
return [
'identifier' => $this->identifier,
'type' => $this->type,
'label' => $this->name,
'name' => $this->name,
'prototypeName' => $this->prototypeName,
'persistenceIdentifier' => $this->persistenceIdentifier ?? $this->identifier,
'invalid' => $this->invalid,
'readOnly' => $this->readOnly,
'removable' => $this->removable,
'storageType' => $this->storageType,
'storageLocation' => $this->storageLocation ?? $this->storageType,
'duplicateIdentifier' => $this->duplicateIdentifier,
'fileUid' => $this->fileUid,
'referenceCount' => $this->referenceCount,
'editUrl' => $this->editUrl,
'actions' => $this->actions,
];
}
private function with(array $changes): self
{
return new self(
identifier: $changes['identifier'] ?? $this->identifier,
type: $changes['type'] ?? $this->type,
name: $changes['name'] ?? $this->name,
prototypeName: $changes['prototypeName'] ?? $this->prototypeName,
persistenceIdentifier: $changes['persistenceIdentifier'] ?? $this->persistenceIdentifier,
invalid: $changes['invalid'] ?? $this->invalid,
readOnly: $changes['readOnly'] ?? $this->readOnly,
removable: $changes['removable'] ?? $this->removable,
storageType: $changes['storageType'] ?? $this->storageType,
duplicateIdentifier: $changes['duplicateIdentifier'] ?? $this->duplicateIdentifier,
fileUid: $changes['fileUid'] ?? $this->fileUid,
referenceCount: $changes['referenceCount'] ?? $this->referenceCount,
editUrl: $changes['editUrl'] ?? $this->editUrl,
storageLocation: $changes['storageLocation'] ?? $this->storageLocation,
actions: $changes['actions'] ?? $this->actions,
);
}
public function withPersistenceIdentifier(string $persistenceIdentifier): self
{
return $this->with(['persistenceIdentifier' => $persistenceIdentifier]);
}
public function withStorageType(string $storageType): self
{
return $this->with(['storageType' => $storageType]);
}
public function withDuplicateIdentifier(bool $duplicateIdentifier): self
{
return $this->with(['duplicateIdentifier' => $duplicateIdentifier]);
}
public function withReadOnly(bool $readOnly): self
{
return $this->with(['readOnly' => $readOnly]);
}
public function withRemovable(bool $removable): self
{
return $this->with(['removable' => $removable]);
}
public function withFileUid(?int $fileUid): self
{
return $this->with(['fileUid' => $fileUid]);
}
public function withReferenceCount(int $referenceCount): self
{
return $this->with(['referenceCount' => $referenceCount]);
}
public function withInvalid(bool $invalid): self
{
return $this->with(['invalid' => $invalid]);
}
public function withEditUrl(string $editUrl): self
{
return $this->with(['editUrl' => $editUrl]);
}
public function withStorageLocation(?string $storageLocation): self
{
return $this->with(['storageLocation' => $storageLocation]);
}
public function withActions(array $actions): self
{
return $this->with(['actions' => $actions]);
}
/**
* Returns a comparable scalar value for the given sort field.
*
* Field names in SearchCriteria::ORDER_FIELDS are intentionally kept
* identical to the property names of this class, so a dynamic lookup
* is sufficient. Unknown fields yield null and are skipped by the
* caller. Booleans are cast to int for correct numeric ordering.
*/
public function getSortableValue(string $field): int|string|null
{
if (!property_exists($this, $field)) {
return null;
}
$value = $this->$field;
if (is_bool($value)) {
return (int)$value;
}
return is_int($value) || is_string($value) ? $value : null;
}
}
@@ -0,0 +1,81 @@
<?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\Form\Domain\DTO;
/**
* Typed representation of the "persistenceManager" section of the form
* YAML configuration.
*
* @internal
*/
final readonly class PersistenceManagerConfiguration
{
/**
* @var list<string>
*/
public const DEFAULT_SORT_BY_KEYS = ['name', 'fileUid'];
/**
* @param list<string> $sortByKeys Keys the forms are sorted by in the form manager and plugin select
* @param list<string> $allowedExtensionPaths EXT: paths that contain forms shipped within extensions
* @param list<string> $allowedFileMounts File mounts forms may be stored in
*/
public function __construct(
public bool $allowSaveToExtensionPaths = false,
public bool $allowDeleteFromExtensionPaths = false,
public array $sortByKeys = self::DEFAULT_SORT_BY_KEYS,
public bool $sortAscending = true,
public array $allowedExtensionPaths = [],
public array $allowedFileMounts = [],
) {}
/**
* Create the DTO from the raw "persistenceManager" configuration array.
*
* @param array<string, mixed> $configuration
*/
public static function fromArray(array $configuration): self
{
return new self(
allowSaveToExtensionPaths: (bool)($configuration['allowSaveToExtensionPaths'] ?? false),
allowDeleteFromExtensionPaths: (bool)($configuration['allowDeleteFromExtensionPaths'] ?? false),
sortByKeys: self::normalizeStringList($configuration['sortByKeys'] ?? null, self::DEFAULT_SORT_BY_KEYS),
sortAscending: (bool)($configuration['sortAscending'] ?? true),
allowedExtensionPaths: self::normalizeStringList($configuration['allowedExtensionPaths'] ?? null, []),
allowedFileMounts: self::normalizeStringList($configuration['allowedFileMounts'] ?? null, []),
);
}
/**
* Normalize a configuration value into a numerically indexed list of strings.
*
* The YAML configuration may use associative keys (e.g. `10:`, `20:`) to
* define ordering, so values are cast to strings and re-indexed.
*
* @param list<string> $default
* @return list<string>
*/
private static function normalizeStringList(mixed $value, array $default): array
{
if (!is_array($value)) {
return $default;
}
return array_values(array_map(strval(...), $value));
}
}
+152
View File
@@ -0,0 +1,152 @@
<?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\Form\Domain\DTO;
use Psr\Http\Message\ServerRequestInterface;
/**
* Search criteria for filtering and sorting form lists
*
* Follows TYPO3 Demand pattern naming conventions:
* - searchTerm: Text to search for in form properties
* - orderField: Field name to sort by
* - orderDirection: Sort direction ('asc' or 'desc')
* - limit: Maximum number of results
*
* @internal
*/
final readonly class SearchCriteria
{
private const string ORDER_ASCENDING = 'asc';
private const string ORDER_DESCENDING = 'desc';
private const string DEFAULT_ORDER_FIELD = 'name';
/**
* Allowed sort fields. Each entry MUST match a public property name of
* FormMetadata exactly, because FormMetadata::getSortableValue() uses
* dynamic property access ($this->$field) instead of an explicit mapping.
*/
private const array ORDER_FIELDS = ['name', 'identifier', 'persistenceIdentifier', 'prototypeName', 'storageLocation', 'duplicateIdentifier', 'referenceCount'];
public string $orderField;
public string $orderDirection;
public function __construct(
public ?string $searchTerm = null,
?string $orderField = null,
?string $orderDirection = null,
public ?int $limit = null,
) {
// Validate and normalize orderField
$this->orderField = in_array($orderField, self::ORDER_FIELDS, true)
? $orderField
: self::DEFAULT_ORDER_FIELD;
// Validate and normalize orderDirection
$this->orderDirection = in_array($orderDirection, [self::ORDER_ASCENDING, self::ORDER_DESCENDING], true)
? $orderDirection
: self::ORDER_ASCENDING;
}
public static function fromArray(array $data): self
{
return new self(
searchTerm: $data['searchTerm'] ?? null,
orderField: $data['orderField'] ?? null,
orderDirection: $data['orderDirection'] ?? null,
limit: $data['limit'] ?? null,
);
}
public static function fromRequest(ServerRequestInterface $request): self
{
$queryParams = $request->getQueryParams();
$parsedBody = $request->getParsedBody() ?? [];
return new self(
searchTerm: $queryParams['searchTerm'] ?? $parsedBody['searchTerm'] ?? null,
orderField: $queryParams['orderField'] ?? $parsedBody['orderField'] ?? null,
orderDirection: $queryParams['orderDirection'] ?? $parsedBody['orderDirection'] ?? null,
limit: isset($queryParams['limit']) ? (int)$queryParams['limit'] : (isset($parsedBody['limit']) ? (int)$parsedBody['limit'] : null),
);
}
public function getOrderField(): string
{
return $this->orderField;
}
public function getOrderDirection(): string
{
return $this->orderDirection;
}
public function getDefaultOrderDirection(): string
{
return self::ORDER_ASCENDING;
}
public function getReverseOrderDirection(): string
{
return $this->orderDirection === self::ORDER_ASCENDING
? self::ORDER_DESCENDING
: self::ORDER_ASCENDING;
}
public function getSearchTerm(): ?string
{
return $this->searchTerm;
}
public function hasSearchTerm(): bool
{
return $this->searchTerm !== null && $this->searchTerm !== '';
}
public function getLimit(): ?int
{
return $this->limit;
}
public function hasLimit(): bool
{
return $this->limit !== null && $this->limit > 0;
}
/**
* Check if any filter/search constraints are set
*/
public function hasConstraints(): bool
{
return $this->hasSearchTerm() || $this->hasLimit();
}
public function getParameters(): array
{
$parameters = [];
if ($this->hasSearchTerm()) {
$parameters['searchTerm'] = $this->searchTerm;
}
if ($this->hasLimit()) {
$parameters['limit'] = $this->limit;
}
$parameters['orderField'] = $this->orderField;
$parameters['orderDirection'] = $this->orderDirection;
return $parameters;
}
}
+36
View File
@@ -0,0 +1,36 @@
<?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\Form\Domain\DTO;
/**
* Storage context for form persistence operations
* Contains additional metadata required for storing forms
*
* @internal
*/
final readonly class StorageContext
{
public function __construct(
public ?int $pid = null,
) {}
public static function create(?int $pid = null): self
{
return new self($pid);
}
}