‪TYPO3CMS  10.4
ItemProcessingService.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 
28 {
40  public function ‪getProcessingItems($table, $pageId, $field, $row, $tcaConfig, $selectedItems)
41  {
42  $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
43  $TSconfig = ‪BackendUtility::getPagesTSconfig($pageId);
44  $fieldTSconfig = $TSconfig['TCEFORM.'][$table . '.'][$field . '.'];
45 
46  $params = [];
47  $params['items'] = &$selectedItems;
48  $params['config'] = $tcaConfig;
49  $params['TSconfig'] = $fieldTSconfig['itemsProcFunc.'];
50  $params['table'] = $table;
51  $params['row'] = $row;
52  $params['field'] = $field;
53 
54  // The itemsProcFunc method may throw an exception.
55  // If it does display an error message and return items unchanged.
56  try {
57  GeneralUtility::callUserFunction($tcaConfig['itemsProcFunc'], $params, $this);
58  } catch (\‪Exception $exception) {
59  $languageService = $this->‪getLanguageService();
60  $fieldLabel = $field;
61  if (isset(‪$GLOBALS['TCA'][$table]['columns'][$field]['label'])) {
62  $fieldLabel = $languageService->sL(‪$GLOBALS['TCA'][$table]['columns'][$field]['label']);
63  }
64  $message = sprintf(
65  $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:error.items_proc_func_error'),
66  $fieldLabel,
67  $exception->getMessage()
68  );
70  $flashMessage = GeneralUtility::makeInstance(
71  FlashMessage::class,
72  $message,
73  '',
75  true
76  );
78  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
79  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
80  $defaultFlashMessageQueue->enqueue($flashMessage);
81  }
82 
83  return $selectedItems;
84  }
85 
89  protected function ‪getLanguageService()
90  {
91  return ‪$GLOBALS['LANG'];
92  }
93 }
‪TYPO3\CMS\Core\DataHandling\ItemProcessingService\getLanguageService
‪LanguageService getLanguageService()
Definition: ItemProcessingService.php:89
‪TYPO3\CMS\Core\DataHandling\ItemProcessingService\getProcessingItems
‪array getProcessingItems($table, $pageId, $field, $row, $tcaConfig, $selectedItems)
Definition: ItemProcessingService.php:40
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Core\DataHandling
Definition: DataHandler.php:16
‪TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig
‪static array getPagesTSconfig($id)
Definition: BackendUtility.php:698
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Core\DataHandling\ItemProcessingService
Definition: ItemProcessingService.php:28
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31