[TASK] Re-work/simplify copyright header in PHP files - Part 1
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Configuration / AbstractCustomPreset.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 custom preset class implements common preset code
21 */
22 abstract class AbstractCustomPreset extends AbstractPreset {
23
24 /**
25 * @var string Name of preset, always set to "Custom"
26 */
27 protected $name = 'Custom';
28
29 /**
30 * @var boolean TRUE if custom preset is active
31 */
32 protected $isActive = FALSE;
33
34 /**
35 * @var integer Priority of custom prefix is usually the lowest
36 */
37 protected $priority = 10;
38
39 /**
40 * Whether custom preset is active is set by feature
41 *
42 * @return boolean TRUE if custom preset is active
43 */
44 public function isActive() {
45 return $this->isActive;
46 }
47
48 /**
49 * Mark preset as active.
50 * The custom features do not know by itself if they are
51 * active or not since the configuration options may overlay
52 * with other presets.
53 * Marking the custom preset as active is therefor taken care
54 * off by the feature itself if no other preset is active.
55 *
56 * @return void
57 */
58 public function setActive() {
59 $this->isActive = TRUE;
60 }
61
62 /**
63 * Custom configuration is always available
64 *
65 * @return boolean TRUE
66 */
67 public function isAvailable() {
68 return TRUE;
69 }
70
71 /**
72 * Get configuration values is used in fluid to show configuration options.
73 * They are fetched from LocalConfiguration / DefaultConfiguration and
74 * merged with given $postValues.
75 *
76 * @return array Configuration values needed to activate prefix
77 */
78 public function getConfigurationValues() {
79 $configurationValues = array();
80 foreach ($this->configurationValues as $configurationKey => $configurationValue) {
81 if (isset($this->postValues['enable'])
82 && $this->postValues['enable'] === $this->name
83 && isset($this->postValues[$this->name][$configurationKey])
84 ) {
85 $currentValue = $this->postValues[$this->name][$configurationKey];
86 } else {
87 $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
88 }
89 $configurationValues[$configurationKey] = $currentValue;
90 }
91 return $configurationValues;
92 }
93 }