‪TYPO3CMS  9.5
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:core/Resources/Private/Language/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 }
‪TYPO3\CMS\Core\DataHandling\ItemProcessingService\getLanguageService
‪LanguageService getLanguageService()
Definition: ItemProcessingService.php:88
‪TYPO3\CMS\Core\DataHandling\ItemProcessingService\getProcessingItems
‪array getProcessingItems($table, $pageId, $field, $row, $tcaConfig, $selectedItems)
Definition: ItemProcessingService.php:39
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\DataHandling
Definition: DataHandler.php:2
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Core\DataHandling\ItemProcessingService
Definition: ItemProcessingService.php:27
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig
‪static array getPagesTSconfig($id, $rootLine=null, $returnPartArray=false)
Definition: BackendUtility.php:864
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:25
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29