Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

NodeDefinition.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 7.52 KiB


 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\Builder;
 013   
 014  use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
 015  use Symfony\Component\Config\Definition\NodeInterface;
 016   
 017  /**
 018   * This class provides a fluent interface for defining a node.
 019   *
 020   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
 021   */
 022  abstract class NodeDefinition implements NodeParentInterface
 023  {
 024      protected $name;
 025      protected $normalization;
 026      protected $validation;
 027      protected $defaultValue;
 028      protected $default = false;
 029      protected $required = false;
 030      protected $deprecationMessage = null;
 031      protected $merge;
 032      protected $allowEmptyValue = true;
 033      protected $nullEquivalent;
 034      protected $trueEquivalent = true;
 035      protected $falseEquivalent = false;
 036      protected $parent;
 037      protected $attributes = [];
 038   
 039      /**
 040       * @param string|null              $name   The name of the node
 041       * @param NodeParentInterface|null $parent The parent
 042       */
 043      public function __construct($name, NodeParentInterface $parent = null)
 044      {
 045          $this->parent = $parent;
 046          $this->name = $name;
 047      }
 048   
 049      /**
 050       * Sets the parent node.
 051       *
 052       * @return $this
 053       */
 054      public function setParent(NodeParentInterface $parent)
 055      {
 056          $this->parent = $parent;
 057   
 058          return $this;
 059      }
 060   
 061      /**
 062       * Sets info message.
 063       *
 064       * @param string $info The info text
 065       *
 066       * @return $this
 067       */
 068      public function info($info)
 069      {
 070          return $this->attribute('info', $info);
 071      }
 072   
 073      /**
 074       * Sets example configuration.
 075       *
 076       * @param string|array $example
 077       *
 078       * @return $this
 079       */
 080      public function example($example)
 081      {
 082          return $this->attribute('example', $example);
 083      }
 084   
 085      /**
 086       * Sets an attribute on the node.
 087       *
 088       * @param string $key
 089       * @param mixed  $value
 090       *
 091       * @return $this
 092       */
 093      public function attribute($key, $value)
 094      {
 095          $this->attributes[$key] = $value;
 096   
 097          return $this;
 098      }
 099   
 100      /**
 101       * Returns the parent node.
 102       *
 103       * @return NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null The builder of the parent node
 104       */
 105      public function end()
 106      {
 107          return $this->parent;
 108      }
 109   
 110      /**
 111       * Creates the node.
 112       *
 113       * @param bool $forceRootNode Whether to force this node as the root node
 114       *
 115       * @return NodeInterface
 116       */
 117      public function getNode($forceRootNode = false)
 118      {
 119          if ($forceRootNode) {
 120              $this->parent = null;
 121          }
 122   
 123          if (null !== $this->normalization) {
 124              $this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
 125          }
 126   
 127          if (null !== $this->validation) {
 128              $this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
 129          }
 130   
 131          $node = $this->createNode();
 132          $node->setAttributes($this->attributes);
 133   
 134          return $node;
 135      }
 136   
 137      /**
 138       * Sets the default value.
 139       *
 140       * @param mixed $value The default value
 141       *
 142       * @return $this
 143       */
 144      public function defaultValue($value)
 145      {
 146          $this->default = true;
 147          $this->defaultValue = $value;
 148   
 149          return $this;
 150      }
 151   
 152      /**
 153       * Sets the node as required.
 154       *
 155       * @return $this
 156       */
 157      public function isRequired()
 158      {
 159          $this->required = true;
 160   
 161          return $this;
 162      }
 163   
 164      /**
 165       * Sets the node as deprecated.
 166       *
 167       * You can use %node% and %path% placeholders in your message to display,
 168       * respectively, the node name and its complete path.
 169       *
 170       * @param string $message Deprecation message
 171       *
 172       * @return $this
 173       */
 174      public function setDeprecated($message = 'The child node "%node%" at path "%path%" is deprecated.')
 175      {
 176          $this->deprecationMessage = $message;
 177   
 178          return $this;
 179      }
 180   
 181      /**
 182       * Sets the equivalent value used when the node contains null.
 183       *
 184       * @param mixed $value
 185       *
 186       * @return $this
 187       */
 188      public function treatNullLike($value)
 189      {
 190          $this->nullEquivalent = $value;
 191   
 192          return $this;
 193      }
 194   
 195      /**
 196       * Sets the equivalent value used when the node contains true.
 197       *
 198       * @param mixed $value
 199       *
 200       * @return $this
 201       */
 202      public function treatTrueLike($value)
 203      {
 204          $this->trueEquivalent = $value;
 205   
 206          return $this;
 207      }
 208   
 209      /**
 210       * Sets the equivalent value used when the node contains false.
 211       *
 212       * @param mixed $value
 213       *
 214       * @return $this
 215       */
 216      public function treatFalseLike($value)
 217      {
 218          $this->falseEquivalent = $value;
 219   
 220          return $this;
 221      }
 222   
 223      /**
 224       * Sets null as the default value.
 225       *
 226       * @return $this
 227       */
 228      public function defaultNull()
 229      {
 230          return $this->defaultValue(null);
 231      }
 232   
 233      /**
 234       * Sets true as the default value.
 235       *
 236       * @return $this
 237       */
 238      public function defaultTrue()
 239      {
 240          return $this->defaultValue(true);
 241      }
 242   
 243      /**
 244       * Sets false as the default value.
 245       *
 246       * @return $this
 247       */
 248      public function defaultFalse()
 249      {
 250          return $this->defaultValue(false);
 251      }
 252   
 253      /**
 254       * Sets an expression to run before the normalization.
 255       *
 256       * @return ExprBuilder
 257       */
 258      public function beforeNormalization()
 259      {
 260          return $this->normalization()->before();
 261      }
 262   
 263      /**
 264       * Denies the node value being empty.
 265       *
 266       * @return $this
 267       */
 268      public function cannotBeEmpty()
 269      {
 270          $this->allowEmptyValue = false;
 271   
 272          return $this;
 273      }
 274   
 275      /**
 276       * Sets an expression to run for the validation.
 277       *
 278       * The expression receives the value of the node and must return it. It can
 279       * modify it.
 280       * An exception should be thrown when the node is not valid.
 281       *
 282       * @return ExprBuilder
 283       */
 284      public function validate()
 285      {
 286          return $this->validation()->rule();
 287      }
 288   
 289      /**
 290       * Sets whether the node can be overwritten.
 291       *
 292       * @param bool $deny Whether the overwriting is forbidden or not
 293       *
 294       * @return $this
 295       */
 296      public function cannotBeOverwritten($deny = true)
 297      {
 298          $this->merge()->denyOverwrite($deny);
 299   
 300          return $this;
 301      }
 302   
 303      /**
 304       * Gets the builder for validation rules.
 305       *
 306       * @return ValidationBuilder
 307       */
 308      protected function validation()
 309      {
 310          if (null === $this->validation) {
 311              $this->validation = new ValidationBuilder($this);
 312          }
 313   
 314          return $this->validation;
 315      }
 316   
 317      /**
 318       * Gets the builder for merging rules.
 319       *
 320       * @return MergeBuilder
 321       */
 322      protected function merge()
 323      {
 324          if (null === $this->merge) {
 325              $this->merge = new MergeBuilder($this);
 326          }
 327   
 328          return $this->merge;
 329      }
 330   
 331      /**
 332       * Gets the builder for normalization rules.
 333       *
 334       * @return NormalizationBuilder
 335       */
 336      protected function normalization()
 337      {
 338          if (null === $this->normalization) {
 339              $this->normalization = new NormalizationBuilder($this);
 340          }
 341   
 342          return $this->normalization;
 343      }
 344   
 345      /**
 346       * Instantiate and configure the node according to this definition.
 347       *
 348       * @return NodeInterface The node instance
 349       *
 350       * @throws InvalidDefinitionException When the definition is invalid
 351       */
 352      abstract protected function createNode();
 353  }
 354