| 1 | 2 | simandl | <?php |
| 2 | | | |
| 3 | | | namespace FreenetRouter\Models\System; |
| 4 | | | |
| 5 | | | use FreenetRouter\Libraries\ConfigEntryManagers\IConfigEntryManager; |
| 6 | | | use Phem\Core\Object; |
| 7 | | | |
| 8 | | | /** |
| 9 | | | * @author Jakub PetrĹžĂlka <kubapet@lbcfree.net> |
| 10 | | | */ |
| 11 | | | class ConfigEntry extends Object |
| 12 | | | { |
| 13 | | | private $name; |
| 14 | | | private $label; |
| 15 | | | private $value; |
| 16 | | | private $configEntryManager; |
| 17 | | | |
| 18 | | | function __construct($name, $label, IConfigEntryManager $cem) |
| 19 | | | { |
| 20 | | | $this->name = $name; |
| 21 | | | $this->label = $label; |
| 22 | | | $this->configEntryManager = $cem; |
| 23 | | | } |
| 24 | | | |
| 25 | | | |
| 26 | | | public function getName() |
| 27 | | | { |
| 28 | | | return $this->name; |
| 29 | | | } |
| 30 | | | |
| 31 | | | public function getLabel() |
| 32 | | | { |
| 33 | | | return $this->label; |
| 34 | | | } |
| 35 | | | |
| 36 | | | public function getValue() |
| 37 | | | { |
| 38 | | | if ($this->value === null) |
| 39 | | | { |
| 40 | | | $this->value = $this->configEntryManager->getValue(); |
| 41 | | | } |
| 42 | | | return $this->value; |
| 43 | | | } |
| 44 | | | |
| 45 | | | public function setName($name) |
| 46 | | | { |
| 47 | | | $this->name = $name; |
| 48 | | | } |
| 49 | | | |
| 50 | | | public function setLabel($label) |
| 51 | | | { |
| 52 | | | $this->label = $label; |
| 53 | | | } |
| 54 | | | |
| 55 | | | public function setValue($value) |
| 56 | | | { |
| 57 | | | $this->configEntryManager->setValue($value); |
| 58 | | | $this->value = $this->configEntryManager->getValue(); |
| 59 | | | } |
| 60 | | | } |