‪TYPO3CMS  10.4
AdditionalResourceService.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 
21 
26 {
30  protected ‪$javaScriptResources = [];
31 
35  protected ‪$stylesheetResources = [];
36 
40  protected ‪$localizationResources = [];
41 
45  public static function ‪getInstance()
46  {
47  return GeneralUtility::makeInstance(AdditionalResourceService::class);
48  }
49 
54  public function ‪addJavaScriptResource($name, $resourcePath)
55  {
56  $this->javaScriptResources[$name] = $this->‪resolvePath($resourcePath);
57  }
58 
63  public function ‪addStylesheetResource($name, $resourcePath)
64  {
65  $this->stylesheetResources[$name] = $this->‪resolvePath($resourcePath);
66  }
67 
71  public function ‪addLocalizationResource($resourcePath)
72  {
73  $absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath);
74  $this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath;
75  }
76 
80  public function ‪getJavaScriptResources()
81  {
83  }
84 
88  public function ‪getStyleSheetResources()
89  {
91  }
92 
96  public function ‪getLocalizationResources()
97  {
99  }
100 
107  protected function ‪resolvePath($resourcePath)
108  {
109  $absoluteFilePath = GeneralUtility::getFileAbsFileName($resourcePath);
110  $absolutePath = ‪PathUtility::dirname($absoluteFilePath);
111  $fileName = ‪PathUtility::basename($absoluteFilePath);
112 
113  return ‪PathUtility::getRelativePathTo($absolutePath) . $fileName;
114  }
115 }
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getInstance
‪static AdditionalResourceService getInstance()
Definition: AdditionalResourceService.php:42
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService
Definition: AdditionalResourceService.php:26
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getLocalizationResources
‪array getLocalizationResources()
Definition: AdditionalResourceService.php:93
‪TYPO3\CMS\Core\Utility\PathUtility\dirname
‪static string dirname($path)
Definition: PathUtility.php:186
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\addLocalizationResource
‪addLocalizationResource($resourcePath)
Definition: AdditionalResourceService.php:68
‪TYPO3\CMS\Workspaces\Service
Definition: AdditionalColumnService.php:16
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\$localizationResources
‪array $localizationResources
Definition: AdditionalResourceService.php:37
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\resolvePath
‪string null resolvePath($resourcePath)
Definition: AdditionalResourceService.php:104
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\$stylesheetResources
‪array $stylesheetResources
Definition: AdditionalResourceService.php:33
‪TYPO3\CMS\Core\Utility\PathUtility\basename
‪static string basename($path)
Definition: PathUtility.php:165
‪TYPO3\CMS\Core\Utility\PathUtility\getRelativePathTo
‪static string null getRelativePathTo($targetPath)
Definition: PathUtility.php:32
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getJavaScriptResources
‪array getJavaScriptResources()
Definition: AdditionalResourceService.php:77
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\addJavaScriptResource
‪addJavaScriptResource($name, $resourcePath)
Definition: AdditionalResourceService.php:51
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\addStylesheetResource
‪addStylesheetResource($name, $resourcePath)
Definition: AdditionalResourceService.php:60
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getStyleSheetResources
‪array getStyleSheetResources()
Definition: AdditionalResourceService.php:85
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\$javaScriptResources
‪array $javaScriptResources
Definition: AdditionalResourceService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46