File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -87,12 +87,19 @@ public function get(string $id): mixed
8787
8888 try {
8989 $ service = call_user_func ($ factory [$ id ], $ this ->wrapperContainer );
90- $ this ->applyServiceExtensions ($ id , $ service );
90+ $ class = get_class ($ service );
91+ $ this ->applyServiceExtensions ($ id , $ class , $ service );
9192 } catch (ContainerExceptionInterface $ containerException ) {
9293 throw ContainerException::forInvalidService ($ id , $ containerException );
9394 }
9495
95- return $ this ->cache [$ id ] = $ service ;
96+ $ this ->cache [$ id ] = $ service ;
97+
98+ if ($ id !== $ class && !isset ($ this ->cache [$ class ])) {
99+ $ this ->cache [$ class ] = $ service ;
100+ }
101+
102+ return $ service ;
96103 }
97104
98105 /**
@@ -118,9 +125,8 @@ public function get(string $id): mixed
118125 *
119126 * @throws ContainerException If any extension fails during invocation.
120127 */
121- private function applyServiceExtensions (string $ id , mixed $ service ): void
128+ private function applyServiceExtensions (string $ id , string $ class , mixed $ service ): void
122129 {
123- $ class = get_class ($ service );
124130 $ extensions = $ this ->serviceProvider ->getExtensions ();
125131
126132 if (\array_key_exists ($ id , $ extensions ) && \is_callable ($ extensions [$ id ])) {
You can’t perform that action at this time.
0 commit comments