Passed
Pull Request — master (#195)
by
unknown
09:41 queued 02:26
created

getDepositLicenseXpath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace EWW\Dpf\Configuration;
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\Extbase\Configuration\BackendConfigurationManager;
18
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
19
use TYPO3\CMS\Extbase\Object\ObjectManager;
20
use EWW\Dpf\Domain\Repository\ClientRepository;
21
22
class ClientConfigurationManager
23
{
24
25
    /**
26
     * objectManager
27
     *
28
     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
29
     * @inject
30
     */
31
    protected $objectManager;
32
33
    /**
34
     * clientRepository
35
     *
36
     * @var \EWW\Dpf\Domain\Repository\ClientRepository
37
     * @inject
38
     */
39
    protected $clientRepository;
40
41
    /**
42
     * settings
43
     *
44
     * @var array
45
     */
46
    protected $settings = array();
47
48
49
    /**
50
     * settings
51
     *
52
     * @var \EWW\Dpf\Domain\Model\Client
53
     */
54
    protected $client = null;
55
56
    /**
57
     * extensionConfiguration
58
     *
59
     * @var array
60
     */
61
    protected $extensionConfiguration = array();
62
63
    public function __construct()
64
    {
65
        $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class);
66
        $clientRepository = $objectManager->get(ClientRepository::class);
67
68
        if (TYPO3_MODE === 'BE') {
0 ignored issues
show
introduced by
The condition EWW\Dpf\Configuration\TYPO3_MODE === 'BE' is always true.
Loading history...
69
            $selectedPageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
70
            if ($selectedPageId) {
71
                $this->client = $clientRepository->findAll()->current();
72
73
                $configurationManager = $objectManager->get(BackendConfigurationManager::class);
74
                $settings = $configurationManager->getConfiguration(null, null);
75
                $this->settings = $settings; //['settings'];
76
            }
77
78
        } else {
79
            $this->client = $clientRepository->findAll()->current();
80
81
            $configurationManager = $objectManager->get(ConfigurationManager::class);
82
            $this->settings = $configurationManager->getConfiguration(
83
                \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS
84
            );
85
86
        }
87
88
        $this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dpf']);
89
    }
90
91
    public function setConfigurationPid($pid)
92
    {
93
        $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class);
94
        $clientRepository = $objectManager->get(ClientRepository::class);
95
96
        $this->client = $clientRepository->findAllByPid($pid)->current();
97
    }
98
99
100
    /**
101
     * Get setting from client or extension configuration.
102
     *
103
     * @var array
104
     */
105
    public function getSetting($settingName, $extConfig = null)
106
    {
107
        $setting = null;
108
        if ($this->client) {
109
            $setting = trim($this->client->{"get" . ucfirst($settingName)}());
110
        }
111
112
        // use global extConfig if client settings is empty
113
        if (empty($setting) && $extConfig) {
114
            $setting = trim($this->extensionConfiguration[$extConfig]);
115
        }
116
117
        return $setting;
118
    }
119
120
121
    public function getOwnerId()
122
    {
123
        return $this->getSetting("ownerId");
124
    }
125
126
    public function getSwordHost()
127
    {
128
        return $this->getSetting("swordHost", "swordHost");
129
    }
130
131
    public function getSwordUser()
132
    {
133
        return $this->getSetting("swordUser", "swordUser");
134
    }
135
136
    public function getSwordPassword()
137
    {
138
        return $this->getSetting("swordPassword", "swordPassword");
139
    }
140
141
    public function getSwordCollectionNamespace()
142
    {
143
        return $this->getSetting("swordCollectionNamespace", "swordCollectionNamespace");
144
    }
145
146
    public function getFedoraHost()
147
    {
148
        return $this->getSetting("fedoraHost", "fedoraHost");
149
    }
150
151
    public function getFedoraUser()
152
    {
153
        return $this->getSetting("fedoraUser", "fedoraUser");
154
    }
155
156
    public function getFedoraPassword()
157
    {
158
        return $this->getSetting("fedoraPassword", "fedoraPassword");
159
    }
160
161
    public function getElasticSearchHost()
162
    {
163
        return $this->getSetting("elasticSearchHost", "elasticSearchHost");
164
    }
165
166
    public function getElasticSearchPort()
167
    {
168
        return $this->getSetting("elasticSearchPort", "elasticSearchPort");
169
    }
170
171
    public function getUploadDirectory()
172
    {
173
        return $this->getSetting("uploadDirectory", "uploadDirectory");
174
    }
175
176
    public function getUploadDomain()
177
    {
178
        return $this->getSetting("uploadDomain", "uploadDomain");
179
    }
180
181
    public function getSuggestionFlashMessage()
182
    {
183
        return $this->getSetting("suggestionFlashmessage", "suggestionFlashmessage");
184
    }
185
186
    public function getFileXpath()
187
    {
188
        return $this->getSetting("fileXpath", "fileXpath");
189
    }
190
191
    public function getStateXpath()
192
    {
193
        return $this->getSetting("stateXpath", "stateXpath");
194
    }
195
196
    public function getTypeXpath()
197
    {
198
        return $this->getSetting("typeXpath", "typeXpath");
199
    }
200
201
    public function getTypeXpathInput()
202
    {
203
        return $this->getSetting("typeXpathInput", "typeXpathInput");
204
    }
205
206
    public function getUrnXpath()
207
    {
208
        return $this->getSetting("urnXpath", "urnXpath");
209
    }
210
211
    public function getQucosaUrnXpath()
212
    {
213
        return $this->getSetting("qucosaUrnXpath", "qucosaUrnXpath");
214
    }
215
216
    public function getDateXpath()
217
    {
218
        return $this->getSetting("dateXpath", "dateXpath");
219
    }
220
221
    public function getPublishingYearXpath()
222
    {
223
        return $this->getSetting("publishingYearXpath", "publishingYearXpath");
224
    }
225
226
    public function getNamespaces()
227
    {
228
        return $this->getSetting("namespaces", "namespaces");
229
    }
230
231
    public function getTitleXpath()
232
    {
233
        return $this->getSetting("titleXpath", "titleXpath");
234
    }
235
236
    public function getOriginalSourceTitleXpath()
237
    {
238
        return $this->getSetting("originalSourceTitleXpath", "originalSourceTitleXpath");
239
    }
240
241
    public function getProcessNumberXpath()
242
    {
243
        return $this->getSetting("processnumberXpath", "processnumberXpath");
244
    }
245
246
    public function getSubmitterNameXpath()
247
    {
248
        return $this->getSetting("submitterNameXpath", "submitterNameXpath");
249
    }
250
251
    public function getSubmitterEmailXpath()
252
    {
253
        return $this->getSetting("submitterEmailXpath", "submitterEmailXpath");
254
    }
255
256
    public function getSubmitterNoticeXpath()
257
    {
258
        return $this->getSetting("submitterNoticeXpath", "submitterNoticeXpath");
259
    }
260
261
    public function getCreatorXpath()
262
    {
263
        return $this->getSetting("creatorXpath", "creatorXpath");
264
    }
265
266
    public function getCreationDateXpath()
267
    {
268
        return $this->getSetting("creationDateXpath", "creationDateXpath");
269
    }
270
271
    public function getRepositoryCreationDateXpath()
272
    {
273
        return $this->getSetting("repositoryCreationDateXpath", "repositoryCreationDateXpath");
274
    }
275
276
    public function getRepositoryLastModDateXpath()
277
    {
278
        return $this->getSetting("repositoryLastModDateXpath", "repositoryLastModDateXpath");
279
    }
280
281
    public function getDepositLicenseXpath()
282
    {
283
        return $this->getSetting("depositLicenseXpath", "depositLicenseXpath");
284
    }
285
286
    public function getAllNotesXpath()
287
    {
288
        return $this->getSetting("allNotesXpath", "allNotesXpath");
289
    }
290
291
    public function getPrivateNotesXpath()
292
    {
293
        return $this->getSetting("privateNotesXpath", "privateNotesXpath");
294
    }
295
296
    public function getInputTransformation()
297
    {
298
        return $this->client->getInputTransformation()->current();
299
    }
300
301
    public function getOutputTransformation()
302
    {
303
        return $this->client->getOutputTransformation()->current();
304
    }
305
306
    public function getPersonXpath()
307
    {
308
        return $this->getSetting("personXpath", "personXpath");
309
    }
310
311
    public function getPersonFamilyXpath()
312
    {
313
        return $this->getSetting("personFamilyXpath", "personFamilyXpath");
314
    }
315
316
    public function getPersonGivenXpath()
317
    {
318
        return $this->getSetting("personGivenXpath", "personGivenXpath");
319
    }
320
321
    public function getPersonRoleXpath()
322
    {
323
        return $this->getSetting("personRoleXpath", "personRoleXpath");
324
    }
325
326
    public function getPersonFisIdentifierXpath()
327
    {
328
        return $this->getSetting("personFisIdentifierXpath", "personFisIdentifierXpath");
329
    }
330
331
    public function getPersonAffiliationXpath()
332
    {
333
        return $this->getSetting("personAffiliationXpath", "personAffiliationXpath");
334
    }
335
336
    public function getPersonAffiliationIdentifierXpath()
337
    {
338
        return $this->getSetting("personAffiliationIdentifierXpath", "personAffiliationIdentifierXpath");
339
    }
340
341
    public function getPersonAuthorRole()
342
    {
343
        return $this->getSetting("personAuthorRole", "personAuthorRole");
344
    }
345
346
    public function getPersonPublisherRole()
347
    {
348
        return $this->getSetting("personPublisherRole", "personPublisherRole");
349
    }
350
351
    public function getValidationXpath()
352
    {
353
        return $this->getSetting("validationXpath", "validationXpath");
354
    }
355
356
    public function fisIdXpath()
357
    {
358
        return $this->getSetting("fisIdXpath", "fisIdXpath");
359
    }
360
361
    public function getSourceDetailsXpaths()
362
    {
363
        return $this->getSetting("sourceDetailsXpaths", "sourceDetailsXpaths");
364
    }
365
366
}
367