20
20
*/
21
21
class ParameterNotFoundException extends InvalidArgumentException implements NotFoundExceptionInterface
22
22
{
23
- private string $ key ;
24
- private ?string $ sourceId ;
25
- private ?string $ sourceKey ;
26
- private array $ alternatives ;
27
- private ?string $ nonNestedAlternative ;
28
-
29
23
/**
30
24
* @param string $key The requested parameter key
31
25
* @param string|null $sourceId The service id that references the non-existent parameter
@@ -34,14 +28,15 @@ class ParameterNotFoundException extends InvalidArgumentException implements Not
34
28
* @param string[] $alternatives Some parameter name alternatives
35
29
* @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters
36
30
*/
37
- public function __construct (string $ key , ?string $ sourceId = null , ?string $ sourceKey = null , ?\Throwable $ previous = null , array $ alternatives = [], ?string $ nonNestedAlternative = null )
38
- {
39
- $ this ->key = $ key ;
40
- $ this ->sourceId = $ sourceId ;
41
- $ this ->sourceKey = $ sourceKey ;
42
- $ this ->alternatives = $ alternatives ;
43
- $ this ->nonNestedAlternative = $ nonNestedAlternative ;
44
-
31
+ public function __construct (
32
+ private string $ key ,
33
+ private ?string $ sourceId = null ,
34
+ private ?string $ sourceKey = null ,
35
+ ?\Throwable $ previous = null ,
36
+ private array $ alternatives = [],
37
+ private ?string $ nonNestedAlternative = null ,
38
+ private ?string $ sourceExtensionName = null ,
39
+ ) {
45
40
parent ::__construct ('' , 0 , $ previous );
46
41
47
42
$ this ->updateRepr ();
@@ -53,6 +48,8 @@ public function updateRepr(): void
53
48
$ this ->message = sprintf ('The service "%s" has a dependency on a non-existent parameter "%s". ' , $ this ->sourceId , $ this ->key );
54
49
} elseif (null !== $ this ->sourceKey ) {
55
50
$ this ->message = sprintf ('The parameter "%s" has a dependency on a non-existent parameter "%s". ' , $ this ->sourceKey , $ this ->key );
51
+ } elseif (null !== $ this ->sourceExtensionName ) {
52
+ $ this ->message = sprintf ('You have requested a non-existent parameter "%s" while loading extension "%s". ' , $ this ->key , $ this ->sourceExtensionName );
56
53
} elseif ('. ' === ($ this ->key [0 ] ?? '' )) {
57
54
$ this ->message = sprintf ('Parameter "%s" not found. It was probably deleted during the compilation of the container. ' , $ this ->key );
58
55
} else {
@@ -99,4 +96,11 @@ public function setSourceKey(?string $sourceKey): void
99
96
100
97
$ this ->updateRepr ();
101
98
}
99
+
100
+ public function setSourceExtensionName (?string $ sourceExtensionName ): void
101
+ {
102
+ $ this ->sourceExtensionName = $ sourceExtensionName ;
103
+
104
+ $ this ->updateRepr ();
105
+ }
102
106
}
0 commit comments