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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ParameterNotFoundException.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.15 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\DependencyInjection\Exception;
13   
14  /**
15   * This exception is thrown when a non-existent parameter is used.
16   *
17   * @author Fabien Potencier <fabien@symfony.com>
18   */
19  class ParameterNotFoundException extends InvalidArgumentException
20  {
21      private $key;
22      private $sourceId;
23      private $sourceKey;
24      private $alternatives;
25      private $nonNestedAlternative;
26   
27      /**
28       * @param string      $key                  The requested parameter key
29       * @param string      $sourceId             The service id that references the non-existent parameter
30       * @param string      $sourceKey            The parameter key that references the non-existent parameter
31       * @param \Exception  $previous             The previous exception
32       * @param string[]    $alternatives         Some parameter name alternatives
33       * @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters
34       */
35      public function __construct($key, $sourceId = null, $sourceKey = null, \Exception $previous = null, array $alternatives = [], $nonNestedAlternative = null)
36      {
37          $this->key = $key;
38          $this->sourceId = $sourceId;
39          $this->sourceKey = $sourceKey;
40          $this->alternatives = $alternatives;
41          $this->nonNestedAlternative = $nonNestedAlternative;
42   
43          parent::__construct('', 0, $previous);
44   
45          $this->updateRepr();
46      }
47   
48      public function updateRepr()
49      {
50          if (null !== $this->sourceId) {
51              $this->message = sprintf('The service "%s" has a dependency on a non-existent parameter "%s".', $this->sourceId, $this->key);
52          } elseif (null !== $this->sourceKey) {
53              $this->message = sprintf('The parameter "%s" has a dependency on a non-existent parameter "%s".', $this->sourceKey, $this->key);
54          } else {
55              $this->message = sprintf('You have requested a non-existent parameter "%s".', $this->key);
56          }
57   
58          if ($this->alternatives) {
59              if (1 == \count($this->alternatives)) {
60                  $this->message .= ' Did you mean this: "';
61              } else {
62                  $this->message .= ' Did you mean one of these: "';
63              }
64              $this->message .= implode('", "', $this->alternatives).'"?';
65          } elseif (null !== $this->nonNestedAlternative) {
66              $this->message .= ' You cannot access nested array items, do you want to inject "'.$this->nonNestedAlternative.'" instead?';
67          }
68      }
69   
70      public function getKey()
71      {
72          return $this->key;
73      }
74   
75      public function getSourceId()
76      {
77          return $this->sourceId;
78      }
79   
80      public function getSourceKey()
81      {
82          return $this->sourceKey;
83      }
84   
85      public function setSourceId($sourceId)
86      {
87          $this->sourceId = $sourceId;
88   
89          $this->updateRepr();
90      }
91   
92      public function setSourceKey($sourceKey)
93      {
94          $this->sourceKey = $sourceKey;
95   
96          $this->updateRepr();
97      }
98  }
99