[CLEANUP] The correct case must be used for standard PHP types in phpdoc
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Service / AdditionalResourceService.php
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
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Service for additional columns in GridPanel
21 */
22 class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface
23 {
24 /**
25 * @var array
26 */
27 protected $javaScriptResources = [];
28
29 /**
30 * @var array
31 */
32 protected $stylesheetResources = [];
33
34 /**
35 * @var array
36 */
37 protected $localizationResources = [];
38
39 /**
40 * @return \TYPO3\CMS\Workspaces\Service\AdditionalResourceService
41 */
42 public static function getInstance()
43 {
44 return self::getObjectManager()->get(\TYPO3\CMS\Workspaces\Service\AdditionalResourceService::class);
45 }
46
47 /**
48 * @return \TYPO3\CMS\Extbase\Object\ObjectManager
49 */
50 public static function getObjectManager()
51 {
52 return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
53 }
54
55 /**
56 * @param string $name
57 * @param string $resourcePath
58 */
59 public function addJavaScriptResource($name, $resourcePath)
60 {
61 $this->javaScriptResources[$name] = $this->resolvePath($resourcePath);
62 }
63
64 /**
65 * @param string $name
66 * @param string $resourcePath
67 */
68 public function addStylesheetResource($name, $resourcePath)
69 {
70 $this->stylesheetResources[$name] = $this->resolvePath($resourcePath);
71 }
72
73 /**
74 * @param string $resourcePath
75 */
76 public function addLocalizationResource($resourcePath)
77 {
78 $absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath);
79 $this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath;
80 }
81
82 /**
83 * @return array
84 */
85 public function getJavaScriptResources()
86 {
87 return $this->javaScriptResources;
88 }
89
90 /**
91 * @return array
92 */
93 public function getStyleSheetResources()
94 {
95 return $this->stylesheetResources;
96 }
97
98 /**
99 * @return array
100 */
101 public function getLocalizationResources()
102 {
103 return $this->localizationResources;
104 }
105
106 /**
107 * Resolve path
108 *
109 * @param string $resourcePath
110 * @return null|string
111 */
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 }