[ Index ]

PHP Cross Reference of phpBB-3.3.7-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Exception/ -> ServiceNotFoundException.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\DependencyInjection\Exception;
  13  
  14  use Psr\Container\NotFoundExceptionInterface;
  15  
  16  /**
  17   * This exception is thrown when a non-existent service is requested.
  18   *
  19   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  20   */
  21  class ServiceNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface
  22  {
  23      private $id;
  24      private $sourceId;
  25      private $alternatives;
  26  
  27      public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = [], $msg = null)
  28      {
  29          if (null !== $msg) {
  30              // no-op
  31          } elseif (null === $sourceId) {
  32              $msg = sprintf('You have requested a non-existent service "%s".', $id);
  33          } else {
  34              $msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
  35          }
  36  
  37          if ($alternatives) {
  38              if (1 == \count($alternatives)) {
  39                  $msg .= ' Did you mean this: "';
  40              } else {
  41                  $msg .= ' Did you mean one of these: "';
  42              }
  43              $msg .= implode('", "', $alternatives).'"?';
  44          }
  45  
  46          parent::__construct($msg, 0, $previous);
  47  
  48          $this->id = $id;
  49          $this->sourceId = $sourceId;
  50          $this->alternatives = $alternatives;
  51      }
  52  
  53      public function getId()
  54      {
  55          return $this->id;
  56      }
  57  
  58      public function getSourceId()
  59      {
  60          return $this->sourceId;
  61      }
  62  
  63      public function getAlternatives()
  64      {
  65          return $this->alternatives;
  66      }
  67  }


Generated: Thu Mar 24 21:31:15 2022 Cross-referenced by PHPXref 0.7.1