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;
|
||||
}
|
||||
Reference in New Issue
Block a user