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