TYPO3 CMS  TYPO3_7-6
ItemProcessingService.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 
22 
27 {
39  public function getProcessingItems($table, $pageId, $field, $row, $tcaConfig, $selectedItems)
40  {
41  $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
42  $TSconfig = BackendUtility::getPagesTSconfig($pageId);
43  $fieldTSconfig = $TSconfig['TCEFORM.'][$table . '.'][$field . '.'];
44 
45  $params = [];
46  $params['items'] = &$selectedItems;
47  $params['config'] = $tcaConfig;
48  $params['TSconfig'] = $fieldTSconfig['itemsProcFunc.'];
49  $params['table'] = $table;
50  $params['row'] = $row;
51  $params['field'] = $field;
52 
53  // The itemsProcFunc method may throw an exception.
54  // If it does display an error message and return items unchanged.
55  try {
56  GeneralUtility::callUserFunction($tcaConfig['itemsProcFunc'], $params, $this);
57  } catch (\Exception $exception) {
58  $languageService = $this->getLanguageService();
59  $fieldLabel = $field;
60  if (isset($GLOBALS['TCA'][$table]['columns'][$field]['label'])) {
61  $fieldLabel = $languageService->sL($GLOBALS['TCA'][$table]['columns'][$field]['label']);
62  }
63  $message = sprintf(
64  $languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.items_proc_func_error'),
65  $fieldLabel,
66  $exception->getMessage()
67  );
69  $flashMessage = GeneralUtility::makeInstance(
70  FlashMessage::class,
71  $message,
72  '',
74  true
75  );
77  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
78  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
79  $defaultFlashMessageQueue->enqueue($flashMessage);
80  }
81 
82  return $selectedItems;
83  }
84 
88  protected function getLanguageService()
89  {
90  return $GLOBALS['LANG'];
91  }
92 }
static getPagesTSconfig($id, $rootLine=null, $returnPartArray=false)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']