|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the TYPO3 CMS project. |
|
5
|
|
|
* |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
8
|
|
|
* of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please read the |
|
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* The TYPO3 project - inspiring people to share! |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace TYPO3\CMS\Workspaces\Service; |
|
17
|
|
|
|
|
18
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
20
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Service for additional columns in GridPanel |
|
24
|
|
|
*/ |
|
25
|
|
|
class AdditionalResourceService implements SingletonInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var array |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $javaScriptResources = []; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var array |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $stylesheetResources = []; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var array |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $localizationResources = []; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return AdditionalResourceService |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function getInstance() |
|
46
|
|
|
{ |
|
47
|
|
|
return GeneralUtility::makeInstance(AdditionalResourceService::class); |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param string $name |
|
52
|
|
|
* @param string $resourcePath |
|
53
|
|
|
*/ |
|
54
|
|
|
public function addJavaScriptResource($name, $resourcePath) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->javaScriptResources[$name] = $this->resolvePath($resourcePath); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string $name |
|
61
|
|
|
* @param string $resourcePath |
|
62
|
|
|
*/ |
|
63
|
|
|
public function addStylesheetResource($name, $resourcePath) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->stylesheetResources[$name] = $this->resolvePath($resourcePath); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param string $resourcePath |
|
70
|
|
|
*/ |
|
71
|
|
|
public function addLocalizationResource($resourcePath) |
|
72
|
|
|
{ |
|
73
|
|
|
$absoluteResourcePath = GeneralUtility::getFileAbsFileName($resourcePath); |
|
74
|
|
|
$this->localizationResources[$absoluteResourcePath] = $absoluteResourcePath; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return array |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getJavaScriptResources() |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->javaScriptResources; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return array |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getStyleSheetResources() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->stylesheetResources; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return array |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getLocalizationResources() |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->localizationResources; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Resolve path |
|
103
|
|
|
* |
|
104
|
|
|
* @param string $resourcePath |
|
105
|
|
|
* @return string|null |
|
106
|
|
|
*/ |
|
107
|
|
|
protected function resolvePath($resourcePath) |
|
108
|
|
|
{ |
|
109
|
|
|
$absoluteFilePath = GeneralUtility::getFileAbsFileName($resourcePath); |
|
110
|
|
|
$absolutePath = PathUtility::dirname($absoluteFilePath); |
|
111
|
|
|
$fileName = PathUtility::basename($absoluteFilePath); |
|
112
|
|
|
|
|
113
|
|
|
return PathUtility::getRelativePathTo($absolutePath) . $fileName; |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
This check looks for accesses to local static members using the fully qualified name instead of
self::.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBCcould just as well be replaced byself::TRIPLEDES_CBC. Referencing local members withself::assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.