‪TYPO3CMS  9.5
AdditionalResourceService.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 
21 
26 {
30  protected ‪$javaScriptResources = [];
31 
35  protected ‪$stylesheetResources = [];
36 
40  protected ‪$localizationResources = [];
41 
45  public static function ‪getInstance()
46  {
47  return ‪self::getObjectManager()->‪get(AdditionalResourceService::class);
48  }
49 
53  public static function ‪getObjectManager()
54  {
55  return GeneralUtility::makeInstance(ObjectManager::class);
56  }
57 
62  public function ‪addJavaScriptResource($name, $resourcePath)
63  {
64  $this->javaScriptResources[$name] = $this->‪resolvePath($resourcePath);
65  }
66 
71  public function ‪addStylesheetResource($name, $resourcePath)
72  {
73  $this->stylesheetResources[$name] = $this->‪resolvePath($resourcePath);
74  }
75 
79  public function ‪addLocalizationResource($resourcePath)
80  {
81  $absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath);
82  $this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath;
83  }
84 
88  public function ‪getJavaScriptResources()
89  {
91  }
92 
96  public function ‪getStyleSheetResources()
97  {
99  }
100 
104  public function ‪getLocalizationResources()
105  {
107  }
108 
115  protected function ‪resolvePath($resourcePath)
116  {
117  $absoluteFilePath = GeneralUtility::getFileAbsFileName($resourcePath);
118  $absolutePath = ‪PathUtility::dirname($absoluteFilePath);
119  $fileName = ‪PathUtility::basename($absoluteFilePath);
120 
121  return ‪PathUtility::getRelativePathTo($absolutePath) . $fileName;
122  }
123 }
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getInstance
‪static AdditionalResourceService getInstance()
Definition: AdditionalResourceService.php:42
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:23
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService
Definition: AdditionalResourceService.php:26
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getLocalizationResources
‪array getLocalizationResources()
Definition: AdditionalResourceService.php:101
‪TYPO3\CMS\Core\Utility\PathUtility\dirname
‪static string dirname($path)
Definition: PathUtility.php:185
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\addLocalizationResource
‪addLocalizationResource($resourcePath)
Definition: AdditionalResourceService.php:76
‪TYPO3\CMS\Workspaces\Service
Definition: AdditionalColumnService.php:2
‪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:112
‪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:164
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getObjectManager
‪static ObjectManager getObjectManager()
Definition: AdditionalResourceService.php:50
‪TYPO3\CMS\Core\Utility\PathUtility\getRelativePathTo
‪static string null getRelativePathTo($targetPath)
Definition: PathUtility.php:31
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getJavaScriptResources
‪array getJavaScriptResources()
Definition: AdditionalResourceService.php:85
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\addJavaScriptResource
‪addJavaScriptResource($name, $resourcePath)
Definition: AdditionalResourceService.php:59
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\addStylesheetResource
‪addStylesheetResource($name, $resourcePath)
Definition: AdditionalResourceService.php:68
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\getStyleSheetResources
‪array getStyleSheetResources()
Definition: AdditionalResourceService.php:93
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extbase\Object\ObjectManager\get
‪object &T get($objectName,... $constructorArguments)
Definition: ObjectManager.php:94
‪TYPO3\CMS\Workspaces\Service\AdditionalResourceService\$javaScriptResources
‪array $javaScriptResources
Definition: AdditionalResourceService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25