File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -177,15 +177,14 @@ public function createService($name, array $args = array())
177177 */
178178 public function getByType ($ class , $ need = TRUE )
179179 {
180- $ names = $ this ->findByType ($ class );
181- if (!$ names ) {
182- if ($ need ) {
183- throw new MissingServiceException ("Service of type $ class not found. " );
184- }
180+ $ class = ltrim ($ class , '\\' );
181+ $ names = & $ this ->meta [self ::TYPES ][$ class ][TRUE ];
182+ if (count ($ names ) === 1 ) {
183+ return $ this ->getService ($ names [0 ]);
185184 } elseif (count ($ names ) > 1 ) {
186185 throw new MissingServiceException ("Multiple services of type $ class found: " . implode (', ' , $ names ) . '. ' );
187- } else {
188- return $ this -> getService ( $ names [ 0 ] );
186+ } elseif ( $ need ) {
187+ throw new MissingServiceException ( " Service of type $ class not found. " );
189188 }
190189 }
191190
You can’t perform that action at this time.
0 commit comments