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