b890fd8e1d1d23a5a14bf7b09d17659344fc47f2
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Configuration / AbstractCustomPreset.php
1 <?php
2 namespace TYPO3\CMS\Install\Configuration;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Core\Utility\GeneralUtility;
28
29 /**
30 * Abstract custom preset class implements common preset code
31 */
32 abstract class AbstractCustomPreset extends AbstractPreset {
33
34 /**
35 * @var string Name of preset, always set to "Custom"
36 */
37 protected $name = 'Custom';
38
39 /**
40 * @var boolean TRUE if custom preset is active
41 */
42 protected $isActive = FALSE;
43
44 /**
45 * @var integer Priority of custom prefix is usually the lowest
46 */
47 protected $priority = 10;
48
49 /**
50 * Whether custom preset is active is set by feature
51 *
52 * @return boolean TRUE if custom preset is active
53 */
54 public function isActive() {
55 return $this->isActive;
56 }
57
58 /**
59 * Mark preset as active.
60 * The custom features do not know by itself if they are
61 * active or not since the configuration options may overlay
62 * with other presets.
63 * Marking the custom preset as active is therefor taken care
64 * off by the feature itself if no other preset is active.
65 *
66 * @return void
67 */
68 public function setActive() {
69 $this->isActive = TRUE;
70 }
71
72 /**
73 * Custom configuration is always available
74 *
75 * @return boolean TRUE
76 */
77 public function isAvailable() {
78 return TRUE;
79 }
80
81 /**
82 * Get configuration values is used in fluid to show configuration options.
83 * They are fetched from LocalConfiguration / DefaultConfiguration and
84 * merged with given $postValues.
85 *
86 * @return array Configuration values needed to activate prefix
87 */
88 public function getConfigurationValues() {
89 $configurationValues = array();
90 foreach ($this->configurationValues as $configurationKey => $configurationValue) {
91 if (isset($this->postValues['enable'])
92 && $this->postValues['enable'] === $this->name
93 && isset($this->postValues[$this->name][$configurationKey])
94 ) {
95 $currentValue = $this->postValues[$this->name][$configurationKey];
96 } else {
97 $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
98 }
99 $configurationValues[$configurationKey] = $currentValue;
100 }
101 return $configurationValues;
102 }
103 }