|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace HDNET\Importr\Domain\Model; |
|
4
|
|
|
|
|
5
|
|
|
use HDNET\Importr\Service\Yaml; |
|
6
|
|
|
use TYPO3\CMS\Core\Core\ApplicationContext; |
|
7
|
|
|
use TYPO3\CMS\Core\LinkHandling\LinkService; |
|
8
|
|
|
use TYPO3\CMS\Core\Resource\FileInterface; |
|
9
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
10
|
|
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Documentation for configuration |
|
14
|
|
|
* |
|
15
|
|
|
* For configuration: |
|
16
|
|
|
* overwriteFilepath: XXXX |
|
17
|
|
|
* |
|
18
|
|
|
* For Resources and Targets: |
|
19
|
|
|
* CLASSNAME: |
|
20
|
|
|
* CLASSNAME-CONFIGURATIONS (see Class) |
|
21
|
|
|
* |
|
22
|
|
|
* @author timlochmueller |
|
23
|
|
|
*/ |
|
24
|
|
|
class Strategy extends AbstractEntity |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $title; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $configuration; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $configurationFile; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $resources; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $resourcesFile; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $targets; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var string |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $targetsFile; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getTitle() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->title; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return string |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getRawConfiguration() |
|
79
|
|
|
{ |
|
80
|
|
|
if ($config = GeneralUtility::getUrl($this->getRealFilePath($this->configurationFile))) { |
|
81
|
|
|
return $config; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return $this->configuration; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return array |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getConfiguration() |
|
91
|
|
|
{ |
|
92
|
|
|
$configuration = Yaml::parse($this->getRawConfiguration()); |
|
93
|
|
|
$configuration['updateInterval'] = (isset($configuration['updateInterval']) && is_numeric($configuration['updateInterval'])) ? $configuration['updateInterval'] : 100; |
|
94
|
|
|
return $configuration; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return string |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getRawResources() |
|
101
|
|
|
{ |
|
102
|
|
|
if ($resources = GeneralUtility::getUrl($this->getRealFilePath($this->resourcesFile))) { |
|
103
|
|
|
return $resources; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return $this->resources; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return array |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getResources() |
|
113
|
|
|
{ |
|
114
|
|
|
return Yaml::parse($this->getRawResources()); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return string |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getRawTargets() |
|
121
|
|
|
{ |
|
122
|
|
|
if ($targets = GeneralUtility::getUrl($this->getRealFilePath($this->targetsFile))) { |
|
123
|
|
|
return $targets; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
return $this->targets; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @return array |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getTargets() |
|
133
|
|
|
{ |
|
134
|
|
|
return Yaml::parse($this->getRawTargets()); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* |
|
139
|
|
|
* @param string $title |
|
140
|
|
|
*/ |
|
141
|
|
|
public function setTitle($title) |
|
142
|
|
|
{ |
|
143
|
|
|
$this->title = $title; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* |
|
148
|
|
|
* @param string $configuration |
|
149
|
|
|
*/ |
|
150
|
|
|
public function setConfiguration($configuration) |
|
151
|
|
|
{ |
|
152
|
|
|
$this->configuration = $configuration; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* |
|
157
|
|
|
* @param string $resources |
|
158
|
|
|
*/ |
|
159
|
|
|
public function setResources($resources) |
|
160
|
|
|
{ |
|
161
|
|
|
$this->resources = $resources; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* |
|
166
|
|
|
* @param string $targets |
|
167
|
|
|
*/ |
|
168
|
|
|
public function setTargets($targets) |
|
169
|
|
|
{ |
|
170
|
|
|
$this->targets = $targets; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @param string $path |
|
175
|
|
|
* @return string |
|
176
|
|
|
*/ |
|
177
|
|
|
private function getRealFilePath($path) |
|
178
|
|
|
{ |
|
179
|
|
|
if (!$path) { |
|
180
|
|
|
return ''; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
if (GeneralUtility::compat_version('8.7')) { |
|
|
|
|
|
|
184
|
|
|
$service = new LinkService(); |
|
185
|
|
|
$data = $service->resolveByStringRepresentation($path); |
|
186
|
|
|
if ($data['file'] instanceof FileInterface) { |
|
187
|
|
|
return $data['file']->getForLocalProcessing(false); |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
return GeneralUtility::getFileAbsFileName($path); |
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.