‪TYPO3CMS  9.5
PhpFrontend.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
32  {
33  parent::__construct(‪$identifier, ‪$backend);
34  }
35 
46  public function set($entryIdentifier, $sourceCode, array $tags = [], $lifetime = null)
47  {
48  if (!$this->‪isValidEntryIdentifier($entryIdentifier)) {
49  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1264023823);
50  }
51  if (!is_string($sourceCode)) {
52  throw new ‪InvalidDataException('The given source code is not a valid string.', 1264023824);
53  }
54  foreach ($tags as $tag) {
55  if (!$this->‪isValidTag($tag)) {
56  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1264023825);
57  }
58  }
59  $sourceCode = '<?php' . LF . $sourceCode . LF . '#';
60  $this->backend->set($entryIdentifier, $sourceCode, $tags, $lifetime);
61  }
62 
70  public function get($entryIdentifier)
71  {
72  if (!$this->‪isValidEntryIdentifier($entryIdentifier)) {
73  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057753);
74  }
75  return $this->backend->get($entryIdentifier);
76  }
77 
86  public function ‪getByTag($tag)
87  {
88  trigger_error('PhpFrontend->getByTag() will be removed in TYPO3 v10.0. Avoid using this method since it is not compliant to PSR-6.', E_USER_DEPRECATED);
89  if (!$this->‪isValidTag($tag)) {
90  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057773);
91  }
92  $entries = [];
93  $identifiers = $this->backend->findIdentifiersByTag($tag);
94  foreach ($identifiers as ‪$identifier) {
95  $entries[] = $this->backend->get(‪$identifier);
96  }
97  return $entries;
98  }
99 
106  public function ‪requireOnce($entryIdentifier)
107  {
108  return $this->backend->requireOnce($entryIdentifier);
109  }
110 
120  public function require(string $entryIdentifier)
121  {
122  return $this->backend->require($entryIdentifier);
123  }
124 }
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend\requireOnce
‪mixed requireOnce($entryIdentifier)
Definition: PhpFrontend.php:106
‪TYPO3\CMS\Core\Cache\Frontend
Definition: AbstractFrontend.php:2
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
Definition: PhpFrontend.php:24
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend\getByTag
‪array getByTag($tag)
Definition: PhpFrontend.php:86
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend\$backend
‪AbstractBackend TaggableBackendInterface $backend
Definition: AbstractFrontend.php:35
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend\__construct
‪__construct($identifier, PhpCapableBackendInterface $backend)
Definition: PhpFrontend.php:31
‪TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface
Definition: PhpCapableBackendInterface.php:22
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend\$identifier
‪string $identifier
Definition: AbstractFrontend.php:31
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend\isValidEntryIdentifier
‪bool isValidEntryIdentifier($identifier)
Definition: AbstractFrontend.php:166
‪TYPO3\CMS\Core\Cache\Exception\InvalidDataException
Definition: InvalidDataException.php:21
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend\isValidTag
‪bool isValidTag($tag)
Definition: AbstractFrontend.php:177
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend
Definition: AbstractFrontend.php:26