Passed
Pull Request — master (#176)
by
unknown
07:42
created

getSuggestionFlashMessage()   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
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
		{
70
            $selectedPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
71
            if ($selectedPageId)
72
            {
73
                $this->client = $clientRepository->findAll()->current();
74
75
                $configurationManager = $objectManager->get(BackendConfigurationManager::class);
76
                $settings = $configurationManager->getConfiguration(NULL,NULL);
77
                $this->settings = $settings; //['settings'];
78
            }
79
80
		}
81
		else
82
		{
83
            $this->client = $clientRepository->findAll()->current();
84
85
            $configurationManager = $objectManager->get(ConfigurationManager::class);
86
    		$this->settings = $configurationManager->getConfiguration(
87
            	\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS
88
        	);
89
90
        }
91
92
        $this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dpf']);
93
    }
94
95
96
    /**
97
     * Get setting from client or extension configuration.
98
     *
99
     * @var array
100
     */
101
    public function getSetting($settingName, $extConfig = NULL)
102
    {
103
        $setting = NULL;
104
        if ($this->client) {
105
            $setting = trim($this->client->{"get".ucfirst($settingName)}());
106
        }
107
108
        // use global extConfig if client settings is empty
109
        if (empty($setting) && $extConfig) {
110
            $setting = trim($this->extensionConfiguration[$extConfig]);
111
        }
112
113
        return $setting;
114
    }
115
116
117
    public function getOwnerId()
118
    {
119
        return $this->getSetting("ownerId");
120
    }
121
122
    public function getSwordHost()
123
    {
124
    	return $this->getSetting("swordHost","swordHost");
125
    }
126
127
	public function getSwordUser()
128
    {
129
    	return $this->getSetting("swordUser","swordUser");
130
    }
131
132
	public function getSwordPassword()
133
    {
134
    	return $this->getSetting("swordPassword","swordPassword");
135
    }
136
137
	public function getSwordCollectionNamespace()
138
    {
139
    	return $this->getSetting("swordCollectionNamespace","swordCollectionNamespace");
140
    }
141
142
	public function getFedoraHost()
143
    {
144
    	return $this->getSetting("fedoraHost","fedoraHost");
145
    }
146
147
	public function getFedoraUser()
148
    {
149
    	return $this->getSetting("fedoraUser","fedoraUser");
150
    }
151
152
	public function getFedoraPassword()
153
    {
154
    	return $this->getSetting("fedoraPassword","fedoraPassword");
155
    }
156
157
	public function getElasticSearchHost()
158
    {
159
    	return $this->getSetting("elasticSearchHost","elasticSearchHost");
160
    }
161
162
	public function getElasticSearchPort()
163
    {
164
    	return $this->getSetting("elasticSearchPort","elasticSearchPort");
165
    }
166
167
	public function getUploadDirectory()
168
    {
169
    	return $this->getSetting("uploadDirectory","uploadDirectory");
170
    }
171
172
	public function getUploadDomain()
173
    {
174
    	return $this->getSetting("uploadDomain","uploadDomain");
175
    }
176
177
    public function getSuggestionFlashMessage()
178
    {
179
        return $this->getSetting("suggestionFlashmessage", "suggestionFlashmessage");
180
    }
181
182
}
183