Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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 /**
031 * {@inheritdoc}
032 */
033 public function setDefaultValue($value)
034 {
035 $this->defaultValueSet = true;
036 $this->defaultValue = $value;
037 }
038
039 /**
040 * {@inheritdoc}
041 */
042 public function hasDefaultValue()
043 {
044 return $this->defaultValueSet;
045 }
046
047 /**
048 * {@inheritdoc}
049 */
050 public function getDefaultValue()
051 {
052 return $this->defaultValue instanceof \Closure ? call_user_func($this->defaultValue) : $this->defaultValue;
053 }
054
055 /**
056 * Sets if this node is allowed to have an empty value.
057 *
058 * @param bool $boolean True if this entity will accept empty values.
059 */
060 public function setAllowEmptyValue($boolean)
061 {
062 $this->allowEmptyValue = (bool) $boolean;
063 }
064
065 /**
066 * {@inheritdoc}
067 */
068 public function setName($name)
069 {
070 $this->name = $name;
071 }
072
073 /**
074 * {@inheritdoc}
075 */
076 protected function validateType($value)
077 {
078 }
079
080 /**
081 * {@inheritdoc}
082 */
083 protected function finalizeValue($value)
084 {
085 if (!$this->allowEmptyValue && empty($value)) {
086 $ex = new InvalidConfigurationException(sprintf(
087 'The path "%s" cannot contain an empty value, but got %s.',
088 $this->getPath(),
089 json_encode($value)
090 ));
091 $ex->setPath($this->getPath());
092
093 throw $ex;
094 }
095
096 return $value;
097 }
098
099 /**
100 * {@inheritdoc}
101 */
102 protected function normalizeValue($value)
103 {
104 return $value;
105 }
106
107 /**
108 * {@inheritdoc}
109 */
110 protected function mergeValues($leftSide, $rightSide)
111 {
112 return $rightSide;
113 }
114 }
115