TYPO3 CMS  TYPO3_7-6
AbstractHandler.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 
20 abstract class AbstractHandler
21 {
27  protected function getCurrentWorkspace()
28  {
29  return $this->getWorkspaceService()->getCurrentWorkspace();
30  }
31 
40  protected function getErrorResponse($errorLabel, $errorCode = 0, $successFlagValue = false)
41  {
42  $localLangFile = 'LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf';
43  $response = [
44  'error' => [
45  'code' => $errorCode,
46  'message' => $GLOBALS['LANG']->sL($localLangFile . ':' . $errorLabel)
47  ],
48  'success' => $successFlagValue
49  ];
50  return $response;
51  }
52 
58  protected function getWorkspaceService()
59  {
60  return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
61  }
62 
70  protected function validateLanguageParameter(\stdClass $parameters)
71  {
72  $language = null;
73  if (isset($parameters->language) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($parameters->language)) {
74  $language = $parameters->language;
75  }
76  return $language;
77  }
78 
88  protected function getAffectedElements(\stdClass $parameters)
89  {
90  $affectedElements = [];
91  if ($parameters->type === 'selection') {
92  foreach ((array)$parameters->selection as $element) {
93  $affectedElements[] = \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord::create($element->table, $element->liveId, $element->versionId);
94  }
95  } elseif ($parameters->type === 'all') {
96  $versions = $this->getWorkspaceService()->selectVersionsInWorkspace($this->getCurrentWorkspace(), 0, -99, -1, 0, 'tables_select', $this->validateLanguageParameter($parameters));
97  foreach ($versions as $table => $tableElements) {
98  foreach ($tableElements as $element) {
99  $affectedElement = \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord::create($table, $element['t3ver_oid'], $element['uid']);
100  $affectedElement->getVersionRecord()->setRow($element);
101  $affectedElements[] = $affectedElement;
102  }
103  }
104  }
105  return $affectedElements;
106  }
107 
116  protected function createIntegrityService(array $affectedElements)
117  {
119  $integrityService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\IntegrityService::class);
120  $integrityService->setAffectedElements($affectedElements);
121  return $integrityService;
122  }
123 }
static create($table, $liveId, $versionId)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
getErrorResponse($errorLabel, $errorCode=0, $successFlagValue=false)