TYPO3 CMS  TYPO3_7-6
AbstractFrontend.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 
21 
28 abstract class AbstractFrontend implements FrontendInterface
29 {
35  protected $identifier;
36 
40  protected $backend;
41 
50  {
51  if (preg_match(self::PATTERN_ENTRYIDENTIFIER, $identifier) !== 1) {
52  throw new \InvalidArgumentException('"' . $identifier . '" is not a valid cache identifier.', 1203584729);
53  }
54  $this->identifier = $identifier;
55  $this->backend = $backend;
56  $this->backend->setCache($this);
57  }
58 
65  public function getIdentifier()
66  {
67  return $this->identifier;
68  }
69 
76  public function getBackend()
77  {
78  return $this->backend;
79  }
80 
89  public function has($entryIdentifier)
90  {
91  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
92  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058486);
93  }
94  return $this->backend->has($entryIdentifier);
95  }
96 
105  public function remove($entryIdentifier)
106  {
107  if (!$this->isValidEntryIdentifier($entryIdentifier)) {
108  throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058495);
109  }
110  return $this->backend->remove($entryIdentifier);
111  }
112 
119  public function flush()
120  {
121  $this->backend->flush();
122  }
123 
132  public function flushByTag($tag)
133  {
134  if (!$this->isValidTag($tag)) {
135  throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057359);
136  }
137  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontend.php']['flushByTag'])) {
138  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/cache/frontend/class.t3lib_cache_frontend_abstractfrontend.php']['flushByTag'] as $_funcRef) {
139  $params = ['tag' => $tag];
140  GeneralUtility::callUserFunction($_funcRef, $params, $this);
141  }
142  }
143  if ($this->backend instanceof TaggableBackendInterface) {
144  $this->backend->flushByTag($tag);
145  }
146  }
147 
154  public function collectGarbage()
155  {
156  $this->backend->collectGarbage();
157  }
158 
167  {
168  return preg_match(self::PATTERN_ENTRYIDENTIFIER, $identifier) === 1;
169  }
170 
178  public function isValidTag($tag)
179  {
180  return preg_match(self::PATTERN_TAG, $tag) === 1;
181  }
182 }
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
__construct($identifier, BackendInterface $backend)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']