Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
VariableNode.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Config\Definition;
013
014 use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
015
016 /**
017 * This node represents a value of variable type in the config tree.
018 *
019 * This node is intended for values of arbitrary type.
020 * Any PHP type is accepted as a value.
021 *
022 * @author Jeremy Mikola <jmikola@gmail.com>
023 */
024 class VariableNode extends BaseNode implements PrototypeNodeInterface
025 {
026 protected $defaultValueSet = false;
027 protected $defaultValue;
028 protected $allowEmptyValue = true;
029
030 public function setDefaultValue($value)
031 {
032 $this->defaultValueSet = true;
033 $this->defaultValue = $value;
034 }
035
036 /**
037 * {@inheritdoc}
038 */
039 public function hasDefaultValue()
040 {
041 return $this->defaultValueSet;
042 }
043
044 /**
045 * {@inheritdoc}
046 */
047 public function getDefaultValue()
048 {
049 $v = $this->defaultValue;
050
051 return $v instanceof \Closure ? $v() : $v;
052 }
053
054 /**
055 * Sets if this node is allowed to have an empty value.
056 *
057 * @param bool $boolean True if this entity will accept empty values
058 */
059 public function setAllowEmptyValue($boolean)
060 {
061 $this->allowEmptyValue = (bool) $boolean;
062 }
063
064 /**
065 * {@inheritdoc}
066 */
067 public function setName($name)
068 {
069 $this->name = $name;
070 }
071
072 /**
073 * {@inheritdoc}
074 */
075 protected function validateType($value)
076 {
077 }
078
079 /**
080 * {@inheritdoc}
081 */
082 protected function finalizeValue($value)
083 {
084 if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
085 $ex = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value)));
086 if ($hint = $this->getInfo()) {
087 $ex->addHint($hint);
088 }
089 $ex->setPath($this->getPath());
090
091 throw $ex;
092 }
093
094 return $value;
095 }
096
097 /**
098 * {@inheritdoc}
099 */
100 protected function normalizeValue($value)
101 {
102 return $value;
103 }
104
105 /**
106 * {@inheritdoc}
107 */
108 protected function mergeValues($leftSide, $rightSide)
109 {
110 return $rightSide;
111 }
112
113 /**
114 * Evaluates if the given value is to be treated as empty.
115 *
116 * By default, PHP's empty() function is used to test for emptiness. This
117 * method may be overridden by subtypes to better match their understanding
118 * of empty data.
119 *
120 * @param mixed $value
121 *
122 * @return bool
123 */
124 protected function isValueEmpty($value)
125 {
126 return empty($value);
127 }
128 }
129