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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

EnumNode.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 1.51 KiB


01  <?php
02   
03  /*
04   * This file is part of the Symfony package.
05   *
06   * (c) Fabien Potencier <fabien@symfony.com>
07   *
08   * For the full copyright and license information, please view the LICENSE
09   * file that was distributed with this source code.
10   */
11   
12  namespace Symfony\Component\Config\Definition;
13   
14  use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
15   
16  /**
17   * Node which only allows a finite set of values.
18   *
19   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
20   */
21  class EnumNode extends ScalarNode
22  {
23      private $values;
24   
25      public function __construct($name, NodeInterface $parent = null, array $values = array())
26      {
27          $values = array_unique($values);
28          if (count($values) <= 1) {
29              throw new \InvalidArgumentException('$values must contain at least two distinct elements.');
30          }
31   
32          parent::__construct($name, $parent);
33          $this->values = $values;
34      }
35   
36      public function getValues()
37      {
38          return $this->values;
39      }
40   
41      protected function finalizeValue($value)
42      {
43          $value = parent::finalizeValue($value);
44   
45          if (!in_array($value, $this->values, true)) {
46              $ex = new InvalidConfigurationException(sprintf(
47                  'The value %s is not allowed for path "%s". Permissible values: %s',
48                  json_encode($value),
49                  $this->getPath(),
50                  implode(', ', array_map('json_encode', $this->values))));
51              $ex->setPath($this->getPath());
52   
53              throw $ex;
54          }
55   
56          return $value;
57      }
58  }
59