NonExistentServiceException.php 883 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Symfony\Component\DependencyInjection\Exception;
  3. /**
  4. * This exception is thrown when a non-existent service is requested.
  5. *
  6. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  7. */
  8. class NonExistentServiceException extends InvalidArgumentException
  9. {
  10. private $id;
  11. private $sourceId;
  12. public function __construct($id, $sourceId = null)
  13. {
  14. if (null === $sourceId) {
  15. $msg = sprintf('You have requested a non-existent service "%s".', $id);
  16. } else {
  17. $msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
  18. }
  19. parent::__construct($msg);
  20. $this->id = $id;
  21. $this->sourceId = $sourceId;
  22. }
  23. public function getId()
  24. {
  25. return $this->id;
  26. }
  27. public function getSourceId()
  28. {
  29. return $this->sourceId;
  30. }
  31. }