TYPO3 CMS  TYPO3_6-2
VariableFrontend.php
Go to the documentation of this file.
1 <?php
3 
26 
33  protected $useIgBinary = FALSE;
34 
40  public function initializeObject() {
41  $this->useIgBinary = extension_loaded('igbinary');
42  }
43 
56  public function set($entryIdentifier, $variable, array $tags = array(), $lifetime = NULL) {
57  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
58  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058264);
59  }
60  foreach ($tags as $tag) {
61  if (!$this->isValidTag($tag)) {
62  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058269);
63  }
64  }
65  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php']['set'])) {
66  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php']['set'] as $_funcRef) {
67  $params = array(
68  'entryIdentifier' => &$entryIdentifier,
69  'variable' => &$variable,
70  'tags' => &$tags,
71  'lifetime' => &$lifetime
72  );
74  }
75  }
76  if ($this->useIgBinary === TRUE) {
77  $this->backend->set($entryIdentifier, igbinary_serialize($variable), $tags, $lifetime);
78  } else {
79  $this->backend->set($entryIdentifier, serialize($variable), $tags, $lifetime);
80  }
81  }
82 
91  public function get($entryIdentifier) {
92  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
93  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058294);
94  }
95  $rawResult = $this->backend->get($entryIdentifier);
96  if ($rawResult === FALSE) {
97  return FALSE;
98  } else {
99  return $this->useIgBinary === TRUE ? igbinary_unserialize($rawResult) : unserialize($rawResult);
100  }
101  }
102 
111  public function getByTag($tag) {
112  if (!$this->isValidTag($tag)) {
113  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233058312);
114  }
115  $entries = array();
116  $identifiers = $this->backend->findIdentifiersByTag($tag);
117  foreach ($identifiers as $identifier) {
118  $rawResult = $this->backend->get($identifier);
119  if ($rawResult !== FALSE) {
120  $entries[] = $this->useIgBinary === TRUE ? igbinary_unserialize($rawResult) : unserialize($rawResult);
121  }
122  }
123  return $entries;
124  }
125 
126 }
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]