TYPO3 CMS  TYPO3_8-7
AbstractPreset.php
Go to the documentation of this file.
1 <?php
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 
19 
23 abstract class AbstractPreset implements PresetInterface
24 {
28  protected $configurationManager = null;
29 
33  protected $name = '';
34 
38  protected $priority = 50;
39 
43  protected $configurationValues = [];
44 
48  protected $postValues = [];
49 
54  {
55  $this->configurationManager = $configurationManager ?: GeneralUtility::makeInstance(ConfigurationManager::class);
56  }
57 
64  public function setPostValues(array $postValues)
65  {
66  $this->postValues = $postValues;
67  }
68 
74  public function getIsAvailable()
75  {
76  return $this->isAvailable();
77  }
78 
84  public function isActive()
85  {
86  $isActive = true;
87  foreach ($this->configurationValues as $configurationKey => $configurationValue) {
88  try {
89  $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
90  } catch (\RuntimeException $e) {
91  $currentValue = null;
92  }
93  if ($currentValue !== $configurationValue) {
94  $isActive = false;
95  break;
96  }
97  }
98  return $isActive;
99  }
100 
106  public function getIsActive()
107  {
108  return $this->isActive();
109  }
110 
116  public function getName()
117  {
118  return $this->name;
119  }
120 
126  public function getPriority()
127  {
128  return $this->priority;
129  }
130 
136  public function getConfigurationValues()
137  {
139  }
140 }
__construct(ConfigurationManager $configurationManager=null)
static makeInstance($className,... $constructorArguments)