Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
basevaluable.php
1<?php
3
5
10abstract class BaseValuable extends Base
11{
12 private $value;
13 private $defaultValue;
14 private $name;
15
21 public function __construct($key)
22 {
23 $this->setKey($key);
24 }
25
29 public function getDefaultValue()
30 {
31 return $this->defaultValue;
32 }
33
40 public function setDefaultValue($defaultValue)
41 {
42 $this->defaultValue = $defaultValue;
43 }
44
45
51 public function getValue()
52 {
53 return $this->value !== null ? $this->value : $this->getDefaultValue();
54 }
55
62 public function setValue($value)
63 {
64 $this->value = $this->normalise($value);
65 }
66
70 public function getName()
71 {
72 return $this->name === null ? $this->getKey() : $this->name;
73 }
74
81 public function setName($name)
82 {
83 $this->name = $name;
84 }
85
86
93 protected function normalise($config)
94 {
95 return $config;
96 }
97
101 public function getId()
102 {
103 $id = parent::getId();
104 if ($id === null)
105 {
106 $id = str_replace('][', '_', $this->getName());
107 $id = str_replace('[', '_', $id);
108 $id = str_replace(']', '', $id);
109 }
110
111 return $id;
112 }
113}