[TASK] Re-work/simplify copyright header in PHP files - Part 9
[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 * Service for additional columns in GridPanel
18 *
19 * @author Oliver Hader <oliver.hader@typo3.org>
20 */
21 class AdditionalResourceService implements \TYPO3\CMS\Core\SingletonInterface {
22
23 /**
24 * @var array
25 */
26 protected $javaScriptResources = array();
27
28 /**
29 * @var array
30 */
31 protected $stylesheetResources = array();
32
33 /**
34 * @return \TYPO3\CMS\Workspaces\Service\AdditionalResourceService
35 */
36 static public function getInstance() {
37 return self::getObjectManager()->get('TYPO3\\CMS\\Workspaces\\Service\\AdditionalResourceService');
38 }
39
40 /**
41 * @return \TYPO3\CMS\Extbase\Object\ObjectManager
42 */
43 static public function getObjectManager() {
44 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
45 }
46
47 /**
48 * @param string $name
49 * @param string $resourcePath
50 * @return void
51 */
52 public function addJavaScriptResource($name, $resourcePath) {
53 $this->javaScriptResources[$name] = $this->resolvePath($resourcePath);
54 }
55
56 /**
57 * @param string $name
58 * @param string $resourcePath
59 * @return void
60 */
61 public function addStylesheetResource($name, $resourcePath) {
62 $this->stylesheetResources[$name] = $this->resolvePath($resourcePath);
63 }
64
65 /**
66 * @return array
67 */
68 public function getJavaScriptResources() {
69 return $this->javaScriptResources;
70 }
71
72 /**
73 * @return array
74 */
75 public function getStyleSheetResources() {
76 return $this->stylesheetResources;
77 }
78
79 /**
80 * @param string $resourcePath
81 * @return NULL|string
82 */
83 protected function resolvePath($resourcePath) {
84 $absoluteFilePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($resourcePath);
85 $absolutePath = dirname($absoluteFilePath);
86 $fileName = basename($absoluteFilePath);
87
88 return \TYPO3\CMS\Core\Utility\PathUtility::getRelativePathTo($absolutePath) . $fileName;
89 }
90
91 }