Drupal investigation

ServiceNotFoundException.php 1.4KB

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