Completed
Push — master ( 6c691f...ec490c )
by Tomas Norre
01:43
created

ExtensionSettingsService::getSetting()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
namespace TNM\GolfCourses\Service;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 3 Nov 2017 Tomas Norre Mikkelsen <[email protected]>
8
 *
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
29
30
/**
31
 * Class ExtensionSettingsService
32
 *
33
 * @package TNM\GolfCourses\Service
34
 */
35
class ExtensionSettingsService
36
{
37
    /**
38
     * @var \TYPO3\CMS\Extbase\Object\ObjectManager
39
     * @inject
40
     */
41
    protected $objectManager;
42
43
    /**
44
     * @param $settingKey
45
     *
46
     * @return string
47
     */
48
    public function getSetting($settingKey)
49
    {
50
        $extensionSetting = $this->getAllSettings();
51
        if ( key_exists($settingKey, $extensionSetting)) {
52
            return $extensionSetting[$settingKey];
53
        }
54
55
        return '';
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    private function getAllSettings()
62
    {
63
        /** @var ConfigurationUtility $configurationUtility */
64
        $configurationUtility = $this->objectManager->get(ConfigurationUtility::class);
65
        return $configurationUtility->getCurrentConfiguration('golf_courses');
66
    }
67
}