TYPO3 CMS  TYPO3_7-6
DataHandlerHook.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 
23 {
36  public function processCmdmap_postProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler $tcemain)
37  {
38  if ($command === 'delete') {
39  if ($table === \TYPO3\CMS\Workspaces\Service\StagesService::TABLE_STAGE) {
40  $this->resetStageOfElements($id);
41  } elseif ($table === \TYPO3\CMS\Workspaces\Service\WorkspaceService::TABLE_WORKSPACE) {
42  $this->flushWorkspaceElements($id);
43  }
44  }
45  }
46 
54  public function processCmdmap_afterFinish(\TYPO3\CMS\Core\DataHandling\DataHandler $tcemainObj)
55  {
56  $this->flushWorkspaceCacheEntriesByWorkspaceId($tcemainObj->BE_USER->workspace);
57  }
58 
67  protected function resetStageOfElements($stageId)
68  {
70  foreach ($this->getTcaTables() as $tcaTable) {
72  $where = 't3ver_stage = ' . (int)$stageId;
73  $where .= ' AND t3ver_wsid > 0 AND pid=-1';
74  $where .= BackendUtility::deleteClause($tcaTable);
75  $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tcaTable, $where, $fields);
76  }
77  }
78  }
79 
86  protected function flushWorkspaceElements($workspaceId)
87  {
88  $command = [];
89  foreach ($this->getTcaTables() as $tcaTable) {
91  $where = '1=1';
92  $where .= BackendUtility::getWorkspaceWhereClause($tcaTable, $workspaceId);
93  $where .= BackendUtility::deleteClause($tcaTable);
94  $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $tcaTable, $where, '', '', '', 'uid');
95  if (is_array($records)) {
96  foreach ($records as $recordId => $_) {
97  $command[$tcaTable][$recordId]['version']['action'] = 'flush';
98  }
99  }
100  }
101  }
102  if (!empty($command)) {
103  $tceMain = $this->getTceMain();
104  $tceMain->start([], $command);
105  $tceMain->process_cmdmap();
106  }
107  }
108 
114  protected function getTcaTables()
115  {
116  return array_keys($GLOBALS['TCA']);
117  }
118 
122  protected function getTceMain()
123  {
124  $tceMain = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
125  $tceMain->stripslashes_values = 0;
126  return $tceMain;
127  }
128 
135  protected function flushWorkspaceCacheEntriesByWorkspaceId($workspaceId)
136  {
137  $workspacesCache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('workspaces_cache');
138  $workspacesCache->flushByTag($workspaceId);
139  $workspacesCache->flushByTag(\TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
140  }
141 }
static getWorkspaceWhereClause($table, $workspaceId=null)
processCmdmap_afterFinish(\TYPO3\CMS\Core\DataHandling\DataHandler $tcemainObj)
processCmdmap_postProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler $tcemain)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static deleteClause($table, $tableAlias='')