namespace Symfony\Component\DependencyInjection\Exception;
+use Psr\Container\NotFoundExceptionInterface;
+
/**
* This exception is thrown when a non-existent service is requested.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
-class ServiceNotFoundException extends InvalidArgumentException
+class ServiceNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface
{
private $id;
private $sourceId;
+ private $alternatives;
- public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = array())
+ public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = array(), $msg = null)
{
- if (null === $sourceId) {
+ if (null !== $msg) {
+ // no-op
+ } elseif (null === $sourceId) {
$msg = sprintf('You have requested a non-existent service "%s".', $id);
} else {
$msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
$this->id = $id;
$this->sourceId = $sourceId;
+ $this->alternatives = $alternatives;
}
public function getId()
{
return $this->sourceId;
}
+
+ public function getAlternatives()
+ {
+ return $this->alternatives;
+ }
}