|
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 /** |
|
15 * This exception is thrown when a non-existent parameter is used. |
|
16 * |
|
17 * @author Fabien Potencier <fabien@symfony.com> |
|
18 */ |
|
19 class ParameterNotFoundException extends InvalidArgumentException |
|
20 { |
|
21 private $key; |
|
22 private $sourceId; |
|
23 private $sourceKey; |
|
24 |
|
25 /** |
|
26 * Constructor. |
|
27 * |
|
28 * @param string $key The requested parameter key |
|
29 * @param string $sourceId The service id that references the non-existent parameter |
|
30 * @param string $sourceKey The parameter key that references the non-existent parameter |
|
31 */ |
|
32 public function __construct($key, $sourceId = null, $sourceKey = null) |
|
33 { |
|
34 $this->key = $key; |
|
35 $this->sourceId = $sourceId; |
|
36 $this->sourceKey = $sourceKey; |
|
37 |
|
38 $this->updateRepr(); |
|
39 } |
|
40 |
|
41 public function updateRepr() |
|
42 { |
|
43 if (null !== $this->sourceId) { |
|
44 $this->message = sprintf('The service "%s" has a dependency on a non-existent parameter "%s".', $this->sourceId, $this->key); |
|
45 } elseif (null !== $this->sourceKey) { |
|
46 $this->message = sprintf('The parameter "%s" has a dependency on a non-existent parameter "%s".', $this->sourceKey, $this->key); |
|
47 } else { |
|
48 $this->message = sprintf('You have requested a non-existent parameter "%s".', $this->key); |
|
49 } |
|
50 } |
|
51 |
|
52 public function getKey() |
|
53 { |
|
54 return $this->key; |
|
55 } |
|
56 |
|
57 public function getSourceId() |
|
58 { |
|
59 return $this->sourceId; |
|
60 } |
|
61 |
|
62 public function getSourceKey() |
|
63 { |
|
64 return $this->sourceKey; |
|
65 } |
|
66 |
|
67 public function setSourceId($sourceId) |
|
68 { |
|
69 $this->sourceId = $sourceId; |
|
70 |
|
71 $this->updateRepr(); |
|
72 } |
|
73 |
|
74 public function setSourceKey($sourceKey) |
|
75 { |
|
76 $this->sourceKey = $sourceKey; |
|
77 |
|
78 $this->updateRepr(); |
|
79 } |
|
80 } |