c2f9ff21825d7da4ae9ed6679404e445aeae4b17
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Configuration / TCA / UserFunctions.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Backend\Configuration\TCA;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use TYPO3\CMS\Core\Localization\LanguageService;
19
20 /**
21 * This class provides user functions for the usage in TCA definition
22 * @internal
23 */
24 class UserFunctions
25 {
26 public function getSiteLanguageTitle(array &$parameters): void
27 {
28 $record = $parameters['row'];
29 $parameters['title'] = sprintf(
30 '%s %s (%s) Base: %s',
31 $record['enabled'] ? '' : '[' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:disabled') . ']',
32 $record['title'],
33 $record['locale'],
34 $record['base']
35 );
36 }
37
38 public function getRouteTitle(array &$parameters): void
39 {
40 $record = $parameters['row'];
41 if ($record['type'][0] === 'uri') {
42 $parameters['title'] = sprintf(
43 '%s %s %s',
44 $record['route'],
45 $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration_tca.xlf:site.routes.irreHeader.redirectsTo'),
46 $record['source'] ?: '[' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:undefined') . ']'
47 );
48 } else {
49 $parameters['title'] = $record['route'];
50 }
51 }
52
53 public function getErrorHandlingTitle(array &$parameters): void
54 {
55 $record = $parameters['row'];
56 $format = '%s: %s';
57 $arguments = [$record['errorCode']];
58 switch ($record['errorHandler'][0]) {
59 case 'Fluid':
60 $arguments[] = $record['errorFluidTemplate'];
61 break;
62 case 'Page':
63 $arguments[] = $record['errorContentSource'];
64 break;
65 case 'PHP':
66 $arguments[] = $record['errorPhpClassFQCN'];
67 break;
68 default:
69 $arguments[] = $record['errorHandler'][0];
70 }
71 $parameters['title'] = sprintf($format, ...$arguments);
72 }
73
74 protected function getLanguageService(): LanguageService
75 {
76 return $GLOBALS['LANG'];
77 }
78 }