TYPO3 CMS  TYPO3_7-6
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 
18 
26 {
39  public function set($entryIdentifier, $string, array $tags = [], $lifetime = null)
40  {
41  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
42  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057566);
43  }
44  if (!is_string($string)) {
45  throw new InvalidDataException('Given data is of type "' . gettype($string) . '", but a string is expected for string cache.', 1222808333);
46  }
47  foreach ($tags as $tag) {
48  if (!$this->isValidTag($tag)) {
49  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057512);
50  }
51  }
52  $this->backend->set($entryIdentifier, $string, $tags, $lifetime);
53  }
54 
63  public function get($entryIdentifier)
64  {
65  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
66  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057752);
67  }
68  return $this->backend->get($entryIdentifier);
69  }
70 
79  public function getByTag($tag)
80  {
81  if (!$this->isValidTag($tag)) {
82  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057772);
83  }
84  $entries = [];
85  $identifiers = $this->backend->findIdentifiersByTag($tag);
86  foreach ($identifiers as $identifier) {
87  $entries[] = $this->backend->get($identifier);
88  }
89  return $entries;
90  }
91 }