‪TYPO3CMS  9.5
StringFrontend.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 
26 {
32  {
33  trigger_error(
34  sprintf(
35  'Usage of class %s will be removed in TYPO3 v10.0, use %s instead',
36  static::class,
37  VariableFrontend::class
38  ),
39  E_USER_DEPRECATED
40  );
41  parent::__construct(‪$identifier, ‪$backend);
42  }
43 
54  public function set($entryIdentifier, $string, array $tags = [], $lifetime = null)
55  {
56  if (!$this->‪isValidEntryIdentifier($entryIdentifier)) {
57  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057566);
58  }
59  if (!is_string($string)) {
60  throw new ‪InvalidDataException('Given data is of type "' . gettype($string) . '", but a string is expected for string cache.', 1222808333);
61  }
62  foreach ($tags as $tag) {
63  if (!$this->‪isValidTag($tag)) {
64  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057512);
65  }
66  }
67  $this->backend->set($entryIdentifier, $string, $tags, $lifetime);
68  }
69 
77  public function get($entryIdentifier)
78  {
79  if (!$this->‪isValidEntryIdentifier($entryIdentifier)) {
80  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057752);
81  }
82  return $this->backend->get($entryIdentifier);
83  }
84 
93  public function ‪getByTag($tag)
94  {
95  trigger_error('StringFrontend->getByTag() will be removed in TYPO3 v10.0. Avoid using this method since it is not compliant to PSR-6.', E_USER_DEPRECATED);
96  if (!$this->‪isValidTag($tag)) {
97  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057772);
98  }
99  $entries = [];
100  $identifiers = $this->backend->findIdentifiersByTag($tag);
101  foreach ($identifiers as ‪$identifier) {
102  $entries[] = $this->backend->get(‪$identifier);
103  }
104  return $entries;
105  }
106 }
‪TYPO3\CMS\Core\Cache\Frontend
Definition: AbstractFrontend.php:2
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend\$backend
‪AbstractBackend TaggableBackendInterface $backend
Definition: AbstractFrontend.php:35
‪TYPO3\CMS\Core\Cache\Backend\BackendInterface
Definition: BackendInterface.php:23
‪TYPO3\CMS\Core\Cache\Frontend\StringFrontend
Definition: StringFrontend.php:26
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend\$identifier
‪string $identifier
Definition: AbstractFrontend.php:31
‪TYPO3\CMS\Core\Cache\Frontend\StringFrontend\getByTag
‪array getByTag($tag)
Definition: StringFrontend.php:93
‪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\StringFrontend\__construct
‪__construct($identifier, BackendInterface $backend)
Definition: StringFrontend.php:31
‪TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend
Definition: AbstractFrontend.php:26