Skip to content

Commit 1f50a37

Browse files
committed
Method for getting specific definition
1 parent 18fdc11 commit 1f50a37

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/DI/ContainerBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ public function getDefinition(string $name): Definition
137137
}
138138

139139

140+
public function getServiceDefinition(string $name): ServiceDefinition
141+
{
142+
$service = $this->getDefinition($name);
143+
if ( ! $service instanceof ServiceDefinition) {
144+
throw new MissingServiceException("Service '$name' not found.");
145+
}
146+
147+
return $service;
148+
}
149+
150+
140151
/**
141152
* Gets all service definitions.
142153
* @return Definition[]

0 commit comments

Comments
 (0)