TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
use TYPO3\CMS\Core\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @internal This is subject to change during v14 development. Do not use.
|
||||
*/
|
||||
final class DefaultPublicFilePrefix implements DynamicPublicPrefixInterface
|
||||
{
|
||||
public function calculatePrefix(PackageInterface $package, PublicResourceDefinition $definition): string
|
||||
{
|
||||
return (new DefaultPublicFolderPrefix())->calculatePrefix($package, $definition) . '/' . basename($definition->getRelativePath());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
use TYPO3\CMS\Core\Core\Environment;
|
||||
use TYPO3\CMS\Core\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @internal This is subject to change during v14 development. Do not use.
|
||||
*/
|
||||
final class DefaultPublicFolderPrefix implements DynamicPublicPrefixInterface
|
||||
{
|
||||
public function calculatePrefix(PackageInterface $package, PublicResourceDefinition $definition): string
|
||||
{
|
||||
return md5(substr($package->getPackagePath() . $definition->getRelativePath(), strlen(Environment::getProjectPath())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
use TYPO3\CMS\Core\Core\Environment;
|
||||
use TYPO3\CMS\Core\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @internal This is subject to change during v14 development. Do not use.
|
||||
*/
|
||||
final class DefaultPublicPrefix implements DynamicPublicPrefixInterface
|
||||
{
|
||||
public function calculatePrefix(PackageInterface $package, PublicResourceDefinition $definition): string
|
||||
{
|
||||
return md5(substr($package->getPackagePath(), strlen(Environment::getProjectPath())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
use TYPO3\CMS\Core\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @internal This is subject to change during v14 development. Do not use.
|
||||
*/
|
||||
interface DynamicPublicPrefixInterface
|
||||
{
|
||||
public function calculatePrefix(PackageInterface $package, PublicResourceDefinition $definition): string;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
/**
|
||||
* This class is meant to be used for resource definition in Configuration/Resources.php
|
||||
*/
|
||||
final readonly class PublicFileDefinition extends PublicResourceDefinition
|
||||
{
|
||||
public function __construct(
|
||||
string $relativePath,
|
||||
string|DynamicPublicPrefixInterface $publicPrefix = new DefaultPublicFilePrefix(),
|
||||
?string $identifier = null,
|
||||
) {
|
||||
parent::__construct($relativePath, $publicPrefix, $identifier);
|
||||
}
|
||||
|
||||
public function matches(string $relativePath): bool
|
||||
{
|
||||
return str_starts_with($relativePath, $this->relativePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
/**
|
||||
* This class is meant to be used for resource definition in Configuration/Resources.php
|
||||
*/
|
||||
readonly class PublicResourceDefinition implements ResourceDefinitionInterface
|
||||
{
|
||||
protected string $identifier;
|
||||
protected string|DynamicPublicPrefixInterface $publicPrefix;
|
||||
|
||||
public function __construct(
|
||||
protected string $relativePath,
|
||||
string|DynamicPublicPrefixInterface|null $publicPrefix = null,
|
||||
?string $identifier = null,
|
||||
) {
|
||||
$this->identifier = $identifier ?? $relativePath;
|
||||
if (is_string($publicPrefix)) {
|
||||
$this->publicPrefix = $publicPrefix;
|
||||
} elseif ($relativePath === 'Resources/Public') {
|
||||
$this->publicPrefix = $publicPrefix ?? new DefaultPublicPrefix();
|
||||
} else {
|
||||
$this->publicPrefix = $publicPrefix ?? new DefaultPublicFolderPrefix();
|
||||
}
|
||||
}
|
||||
|
||||
public function matches(string $relativePath): bool
|
||||
{
|
||||
return str_starts_with($relativePath, $this->relativePath . '/');
|
||||
}
|
||||
|
||||
public function getPublicPrefix(): DynamicPublicPrefixInterface|string
|
||||
{
|
||||
return $this->publicPrefix;
|
||||
}
|
||||
|
||||
public function getRelativePath(): string
|
||||
{
|
||||
return $this->relativePath;
|
||||
}
|
||||
|
||||
public function getIdentifier(): string
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
/**
|
||||
* This class is meant to be used for resource definition in Configuration/Resources.php
|
||||
*/
|
||||
final readonly class ResourceDefinition implements ResourceDefinitionInterface
|
||||
{
|
||||
public function __construct(
|
||||
private string $relativePath,
|
||||
) {}
|
||||
|
||||
public function matches(string $relativePath): bool
|
||||
{
|
||||
return str_starts_with($relativePath, $this->relativePath);
|
||||
}
|
||||
|
||||
public function getRelativePath(): string
|
||||
{
|
||||
return $this->relativePath;
|
||||
}
|
||||
|
||||
public function getIdentifier(): string
|
||||
{
|
||||
return $this->relativePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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\Core\Package\Resource\Definition;
|
||||
|
||||
/**
|
||||
* @internal This interface is only meant to be used in TYPO3\CMS\Core\Package\Resource\Definition namespace
|
||||
*/
|
||||
interface ResourceDefinitionInterface
|
||||
{
|
||||
public function matches(string $relativePath): bool;
|
||||
public function getRelativePath(): string;
|
||||
public function getIdentifier(): string;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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\Core\Package\Resource;
|
||||
|
||||
use TYPO3\CMS\Core\Package\Resource\Definition\PublicResourceDefinition;
|
||||
use TYPO3\CMS\Core\Package\Resource\Definition\ResourceDefinition;
|
||||
use TYPO3\CMS\Core\Package\Resource\Definition\ResourceDefinitionInterface;
|
||||
use TYPO3\CMS\Core\SystemResource\Exception\SystemResourceDefinitionNotFoundException;
|
||||
|
||||
/**
|
||||
* @internal This is subject to change during v14 development. Do not use.
|
||||
*/
|
||||
final readonly class ResourceCollection implements ResourceCollectionInterface
|
||||
{
|
||||
/**
|
||||
* @param list<ResourceDefinitionInterface> $resourceDefinitions
|
||||
*/
|
||||
public function __construct(
|
||||
private array $resourceDefinitions = [],
|
||||
private ?string $iconIdentifier = null,
|
||||
private bool $createResourcesOnTheFly = true,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @internal Only to be used in VirtualAppPackage. Will be removed when deprecated asset config is removed
|
||||
*/
|
||||
public function withAdditionalResources(self $resources): ResourceCollectionInterface
|
||||
{
|
||||
return new self(
|
||||
array_merge($this->resourceDefinitions, $resources->resourceDefinitions),
|
||||
$this->iconIdentifier,
|
||||
);
|
||||
}
|
||||
|
||||
public function definitionForPath(string $relativePath): ResourceDefinitionInterface
|
||||
{
|
||||
foreach ($this->resourceDefinitions as $config) {
|
||||
if ($config->matches($relativePath)) {
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
if ($this->createResourcesOnTheFly) {
|
||||
trigger_error('Resource identifiers outside ouf Resources/Private, Resources/Public or Configuration folder of extensions are deprecated. Define custom resources if required. Used resource: ' . $relativePath, E_USER_DEPRECATED);
|
||||
return new ResourceDefinition($relativePath);
|
||||
}
|
||||
throw new SystemResourceDefinitionNotFoundException(sprintf('Project path "%s" is not allowed. Define custom resources if required.', $relativePath), 1763381519);
|
||||
}
|
||||
|
||||
public function isPublicPath(string $relativePath): bool
|
||||
{
|
||||
return $this->definitionForPath($relativePath) instanceof PublicResourceDefinition;
|
||||
}
|
||||
|
||||
public function getPublicResourceDefinitions(): array
|
||||
{
|
||||
return array_filter(
|
||||
array_map(
|
||||
static fn(ResourceDefinitionInterface $definition) => $definition instanceof PublicResourceDefinition ? $definition : null,
|
||||
$this->resourceDefinitions,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getPackageIcon(): ?string
|
||||
{
|
||||
return $this->iconIdentifier;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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\Core\Package\Resource;
|
||||
|
||||
use TYPO3\CMS\Core\Package\Resource\Definition\PublicResourceDefinition;
|
||||
use TYPO3\CMS\Core\Package\Resource\Definition\ResourceDefinitionInterface;
|
||||
|
||||
/**
|
||||
* @internal This is subject to change during v14 development. Do not use.
|
||||
*/
|
||||
interface ResourceCollectionInterface
|
||||
{
|
||||
public function isPublicPath(string $relativePath): bool;
|
||||
|
||||
public function definitionForPath(string $relativePath): ResourceDefinitionInterface;
|
||||
|
||||
public function getPackageIcon(): ?string;
|
||||
|
||||
/**
|
||||
* @return PublicResourceDefinition[]
|
||||
*/
|
||||
public function getPublicResourceDefinitions(): array;
|
||||
}
|
||||
Reference in New Issue
Block a user