TYPO3 CMS  TYPO3_8-7
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 
18 
23 {
27  protected $javaScriptResources = [];
28 
32  protected $stylesheetResources = [];
33 
37  protected $localizationResources = [];
38 
42  public static function getInstance()
43  {
44  return self::getObjectManager()->get(\TYPO3\CMS\Workspaces\Service\AdditionalResourceService::class);
45  }
46 
50  public static function getObjectManager()
51  {
52  return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
53  }
54 
59  public function addJavaScriptResource($name, $resourcePath)
60  {
61  $this->javaScriptResources[$name] = $this->resolvePath($resourcePath);
62  }
63 
68  public function addStylesheetResource($name, $resourcePath)
69  {
70  $this->stylesheetResources[$name] = $this->resolvePath($resourcePath);
71  }
72 
76  public function addLocalizationResource($resourcePath)
77  {
78  $absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath);
79  $this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath;
80  }
81 
85  public function getJavaScriptResources()
86  {
88  }
89 
93  public function getStyleSheetResources()
94  {
96  }
97 
101  public function getLocalizationResources()
102  {
104  }
105 
112  protected function resolvePath($resourcePath)
113  {
114  $absoluteFilePath = GeneralUtility::getFileAbsFileName($resourcePath);
115  $absolutePath = dirname($absoluteFilePath);
116  $fileName = basename($absoluteFilePath);
117 
118  return \TYPO3\CMS\Core\Utility\PathUtility::getRelativePathTo($absolutePath) . $fileName;
119  }
120 }
static getFileAbsFileName($filename, $_=null, $_2=null)
static makeInstance($className,... $constructorArguments)