TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AdditionalResourceService.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Service;
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 
60  public function addJavaScriptResource($name, $resourcePath)
61  {
62  $this->javaScriptResources[$name] = $this->resolvePath($resourcePath);
63  }
64 
70  public function addStylesheetResource($name, $resourcePath)
71  {
72  $this->stylesheetResources[$name] = $this->resolvePath($resourcePath);
73  }
74 
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 = dirname($absoluteFilePath);
119  $fileName = basename($absoluteFilePath);
120 
121  return \TYPO3\CMS\Core\Utility\PathUtility::getRelativePathTo($absolutePath) . $fileName;
122  }
123 }
static makeInstance($className,...$constructorArguments)
static getFileAbsFileName($filename, $_=null, $_2=null)