‪TYPO3CMS  ‪main
PackageDependentCacheIdentifier.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\CMS\Core\Package\PackageManager;
23 
30 {
31  private string ‪$baseIdentifier;
32  private string ‪$prefix = '';
33  private string ‪$additionalIdentifier = '';
34 
35  public function ‪__construct(PackageManager $packageManager)
36  {
37  $this->baseIdentifier = (new ‪Typo3Version())->getVersion() . ‪Environment::getProjectPath() . ($packageManager->getCacheIdentifier() ?? '');
38  }
39 
40  public function ‪toString(): string
41  {
42  return $this->‪prefix . sha1($this->baseIdentifier . $this->additionalIdentifier);
43  }
44 
45  public function ‪withPrefix(string ‪$prefix): self
46  {
47  $newIdentifier = clone $this;
48  $newIdentifier->prefix = ‪$prefix . '_';
49 
50  return $newIdentifier;
51  }
52 
54  {
55  $newIdentifier = clone $this;
56  $newIdentifier->additionalIdentifier = ‪$additionalIdentifier;
57 
58  return $newIdentifier;
59  }
60 }
‪TYPO3\CMS\Core\Information\Typo3Version
Definition: Typo3Version.php:21
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier
Definition: PackageDependentCacheIdentifier.php:30
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\$additionalIdentifier
‪string $additionalIdentifier
Definition: PackageDependentCacheIdentifier.php:33
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\toString
‪toString()
Definition: PackageDependentCacheIdentifier.php:40
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:160
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\__construct
‪__construct(PackageManager $packageManager)
Definition: PackageDependentCacheIdentifier.php:35
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\withPrefix
‪withPrefix(string $prefix)
Definition: PackageDependentCacheIdentifier.php:45
‪TYPO3\CMS\Core\Package\Cache
Definition: ComposerPackageArtifact.php:18
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\$baseIdentifier
‪string $baseIdentifier
Definition: PackageDependentCacheIdentifier.php:31
‪TYPO3\CMS\Extbase\Security\prefix
‪@ prefix
Definition: HashScope.php:30
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\withAdditionalHashedIdentifier
‪withAdditionalHashedIdentifier(string $additionalIdentifier)
Definition: PackageDependentCacheIdentifier.php:53
‪TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier\$prefix
‪string $prefix
Definition: PackageDependentCacheIdentifier.php:32