File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/DependencyInjection/Nette Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 1717final class NetteContainer implements Container
1818{
1919
20- public function __construct (private \Nette \DI \Container $ container )
20+ /** @var mixed[] */
21+ private ?array $ parameters = null ;
22+
23+ public function __construct (
24+ private readonly \Nette \DI \Container $ container ,
25+ )
2126 {
2227 }
2328
@@ -74,24 +79,28 @@ public function getServicesByTag(string $tagName): array
7479 */
7580 public function getParameters (): array
7681 {
77- return $ this ->container ->getParameters ();
82+ return $ this ->parameters ??= $ this -> container ->getParameters ();
7883 }
7984
8085 public function hasParameter (string $ parameterName ): bool
8186 {
82- return array_key_exists ($ parameterName , $ this ->container ->getParameters ());
87+ $ parameters = $ this ->parameters ??= $ this ->container ->getParameters ();
88+
89+ return array_key_exists ($ parameterName , $ parameters );
8390 }
8491
8592 /**
8693 * @return mixed
8794 */
8895 public function getParameter (string $ parameterName )
8996 {
90- if (!$ this ->hasParameter ($ parameterName )) {
97+ $ parameters = $ this ->parameters ??= $ this ->container ->getParameters ();
98+
99+ if (!array_key_exists ($ parameterName , $ parameters )) {
91100 throw new ParameterNotFoundException ($ parameterName );
92101 }
93102
94- return $ this -> container -> getParameter ( $ parameterName) ;
103+ return $ parameters [ $ parameterName] ;
95104 }
96105
97106 /**
You can’t perform that action at this time.
0 commit comments