‪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 
23 use TYPO3\CMS\Core\Page\JavaScriptItems;
27 
36 {
37  protected function ‪addJavaScriptModulesToJavaScriptItems(array $modules, JavaScriptItems $items): void
38  {
39  foreach ($modules as $module) {
40  if (!$module instanceof ‪JavaScriptModuleInstruction) {
41  throw new \LogicException(
42  sprintf(
43  'Module must be a %s, type "%s" given',
44  JavaScriptModuleInstruction::class,
45  gettype($module)
46  ),
47  1663851377
48  );
49  }
50  $items->addJavaScriptModuleInstruction($module);
51  }
52  }
53 
60  protected function ‪getRelativePathToStylesheetFile(string $stylesheetFile): string
61  {
62  if (‪PathUtility::isExtensionPath($stylesheetFile)) {
63  // @see PageRenderer::getStreamlinedFileName()
64  $stylesheetFile = ‪Environment::getPublicPath() . '/' . ‪PathUtility::getPublicResourceWebPath($stylesheetFile, false);
65  $stylesheetFile = ‪PathUtility::getRelativePathTo($stylesheetFile) ?? '';
66  $stylesheetFile = rtrim($stylesheetFile, '/');
67  } else {
68  $stylesheetFile = GeneralUtility::resolveBackPath($stylesheetFile);
69  }
70  $stylesheetFile = GeneralUtility::createVersionNumberedFilename($stylesheetFile);
71  return ‪PathUtility::getAbsoluteWebPath($stylesheetFile);
72  }
73 
80  protected function ‪getLabelsFromLocalizationFile(string $file): array
81  {
82  $languageService = $this->‪getLanguageService() ?? GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
83  return $languageService->getLabelsFromResource($file);
84  }
85 
87  {
88  return ‪$GLOBALS['LANG'] ?? null;
89  }
90 }
‪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\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪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:80
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\getRelativePathToStylesheetFile
‪string getRelativePathToStylesheetFile(string $stylesheetFile)
Definition: AbstractFormEngineAjaxController.php:60
‪TYPO3\CMS\Core\Utility\PathUtility\getPublicResourceWebPath
‪static getPublicResourceWebPath(string $resourcePath, bool $prefixWithSitePath=true)
Definition: PathUtility.php:97
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\getLanguageService
‪getLanguageService()
Definition: AbstractFormEngineAjaxController.php:86
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController\addJavaScriptModulesToJavaScriptItems
‪addJavaScriptModulesToJavaScriptItems(array $modules, JavaScriptItems $items)
Definition: AbstractFormEngineAjaxController.php:37
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController
Definition: AbstractFormEngineAjaxController.php:36
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Controller
Definition: AboutController.php:18