TYPO3 CMS  TYPO3_8-7
VariableFrontend.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 {
36  public function set($entryIdentifier, $variable, array $tags = [], $lifetime = null)
37  {
38  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
39  throw new \InvalidArgumentException(
40  '"' . $entryIdentifier . '" is not a valid cache entry identifier.',
41  1233058264
42  );
43  }
44  foreach ($tags as $tag) {
45  if (!$this->isValidTag($tag)) {
46  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058269);
47  }
48  }
49  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php']['set'])) {
50  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php']['set'] as $_funcRef) {
51  $params = [
52  'entryIdentifier' => &$entryIdentifier,
53  'variable' => &$variable,
54  'tags' => &$tags,
55  'lifetime' => &$lifetime
56  ];
57  GeneralUtility::callUserFunction($_funcRef, $params, $this);
58  }
59  }
60  if (!$this->backend instanceof TransientBackendInterface) {
61  $variable = serialize($variable);
62  }
63  $this->backend->set($entryIdentifier, $variable, $tags, $lifetime);
64  }
65 
75  public function get($entryIdentifier)
76  {
77  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
78  throw new \InvalidArgumentException(
79  '"' . $entryIdentifier . '" is not a valid cache entry identifier.',
80  1233058294
81  );
82  }
83  $rawResult = $this->backend->get($entryIdentifier);
84  if ($rawResult === false) {
85  return false;
86  }
87  return $this->backend instanceof TransientBackendInterface ? $rawResult : unserialize($rawResult);
88  }
89 
99  public function getByTag($tag)
100  {
101  if (!$this->isValidTag($tag)) {
102  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058312);
103  }
104  $entries = [];
105  $identifiers = $this->backend->findIdentifiersByTag($tag);
106  foreach ($identifiers as $identifier) {
107  $rawResult = $this->backend->get($identifier);
108  if ($rawResult !== false) {
109  $entries[] = $this->backend instanceof TransientBackendInterface ? $rawResult : unserialize($rawResult);
110  }
111  }
112  return $entries;
113  }
114 }
static callUserFunction($funcName, &$params, &$ref, $_='', $errorMode=0)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']