[TASK] Re-work/simplify copyright header in PHP files - Part 1
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Configuration / AbstractPreset.php
1 <?php
2 namespace TYPO3\CMS\Install\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\Core\Utility\GeneralUtility;
18
19 /**
20 * Abstract preset class implements common preset code
21 */
22 abstract class AbstractPreset implements PresetInterface {
23
24 /**
25 * @var \TYPO3\CMS\Core\Configuration\ConfigurationManager
26 * @inject
27 */
28 protected $configurationManager = NULL;
29
30 /**
31 * @var string Name of preset, must be set by extending classes
32 */
33 protected $name = '';
34
35 /**
36 * @var integer Default priority of preset
37 */
38 protected $priority = 50;
39
40 /**
41 * @var array Configuration values handled by this preset
42 */
43 protected $configurationValues = array();
44
45 /**
46 * @var array List of $POST values
47 */
48 protected $postValues = array();
49
50 /**
51 * Set POST values
52 *
53 * @param array $postValues Post values of feature
54 * @return mixed
55 */
56 public function setPostValues(array $postValues) {
57 $this->postValues = $postValues;
58 }
59
60 /**
61 * Wrapper for isAvailable, used in fluid
62 *
63 * @return boolean TRUE if preset is available
64 */
65 public function getIsAvailable() {
66 return $this->isAvailable();
67 }
68
69 /**
70 * Check is preset is currently active on the system
71 *
72 * @return boolean TRUE if preset is active
73 */
74 public function isActive() {
75 $isActive = TRUE;
76 foreach ($this->configurationValues as $configurationKey => $configurationValue) {
77 try {
78 $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
79 } catch (\RuntimeException $e) {
80 $currentValue = NULL;
81 }
82 if ($currentValue !== $configurationValue) {
83 $isActive = FALSE;
84 break;
85 }
86 }
87 return $isActive;
88 }
89
90 /**
91 * Wrapper for isActive, used in fluid
92 *
93 * @return boolean TRUE if preset is active
94 */
95 public function getIsActive() {
96 return $this->isActive();
97 }
98
99 /**
100 * Get name of preset
101 *
102 * @return string Name
103 */
104 public function getName() {
105 return $this->name;
106 }
107
108 /**
109 * Get priority of preset
110 *
111 * @return integer Priority, usually between 0 and 100
112 */
113 public function getPriority() {
114 return $this->priority;
115 }
116
117 /**
118 * Get configuration values to activate prefix
119 *
120 * @return array Configuration values needed to activate prefix
121 */
122 public function getConfigurationValues() {
123 return $this->configurationValues;
124 }
125 }