‪TYPO3CMS  ‪main
AbstractFormEngineAjaxController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
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 
19 
22 use TYPO3\CMS\Core\Page\JavaScriptItems;
26 
35 {
36  protected function ‪addJavaScriptModulesToJavaScriptItems(array $modules, JavaScriptItems $items): void
37  {
38  foreach ($modules as $module) {
39  if (!$module instanceof ‪JavaScriptModuleInstruction) {
40  throw new \LogicException(
41  sprintf(
42  'Module must be a %s, type "%s" given',
43  JavaScriptModuleInstruction::class,
44  gettype($module)
45  ),
46  1663851377
47  );
48  }
49  $items->addJavaScriptModuleInstruction($module);
50  }
51  }
52 
59  protected function ‪getRelativePathToStylesheetFile(string $stylesheetFile): string
60  {
61  if (‪PathUtility::isExtensionPath($stylesheetFile)) {
62  $stylesheetFile = GeneralUtility::getFileAbsFileName($stylesheetFile);
63  $stylesheetFile = ‪PathUtility::getRelativePathTo($stylesheetFile) ?? '';
64  $stylesheetFile = rtrim($stylesheetFile, '/');
65  } else {
66  $stylesheetFile = GeneralUtility::resolveBackPath($stylesheetFile);
67  }
68  $stylesheetFile = GeneralUtility::createVersionNumberedFilename($stylesheetFile);
69  return ‪PathUtility::getAbsoluteWebPath($stylesheetFile);
70  }
71 
78  protected function ‪getLabelsFromLocalizationFile(string $file): array
79  {
80  $languageService = $this->‪getLanguageService() ?? GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
81  return $languageService->getLabelsFromResource($file);
82  }
83 
85  {
86  return ‪$GLOBALS['LANG'] ?? null;
87  }
88 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Utility\PathUtility\isExtensionPath
‪static isExtensionPath(string $path)
Definition: PathUtility.php:117
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Utility\PathUtility\getRelativePathTo
‪static getRelativePathTo(string $absolutePath)
Definition: PathUtility.php:33
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction
Definition: JavaScriptModuleInstruction.php:23
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath(string $targetPath, bool $prefixWithSitePath=true)
Definition: PathUtility.php:52
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\getLabelsFromLocalizationFile
‪array getLabelsFromLocalizationFile(string $file)
Definition: AbstractFormEngineAjaxController.php:78
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\getRelativePathToStylesheetFile
‪string getRelativePathToStylesheetFile(string $stylesheetFile)
Definition: AbstractFormEngineAjaxController.php:59
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\getLanguageService
‪getLanguageService()
Definition: AbstractFormEngineAjaxController.php:84
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\addJavaScriptModulesToJavaScriptItems
‪addJavaScriptModulesToJavaScriptItems(array $modules, JavaScriptItems $items)
Definition: AbstractFormEngineAjaxController.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController
Definition: AbstractFormEngineAjaxController.php:35
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Backend\Controller
Definition: AboutController.php:18