Skip to content

Commit

Permalink
Do not error when a service decorates an unknown service. (mglaman#622)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Glaman <[email protected]>
  • Loading branch information
cmlara and mglaman authored Nov 9, 2023
1 parent b7039ae commit bde6445
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Drupal/ServiceMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public function setDrupalServices(array $drupalServices): void

foreach ($decorators as $decorated_service_id => $services) {
foreach ($services as $dcorating_service_id) {
if (!isset(self::$services[$decorated_service_id])) {
continue;
}
self::$services[$decorated_service_id]->addDecorator(self::$services[$dcorating_service_id]);
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/src/ServiceMapFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public function testFactory(string $id, callable $validator): void
'decorates' => 'service_map.deocrating_base',
'class' => 'Drupal\service_map\Override',
],
'decorating_an_unknown_service' => [
'decorates' => 'unknown',
'class' => 'Drupal\service_map\Override',
],
]);
$validator($service->getService($id));
}
Expand Down

0 comments on commit bde6445

Please sign in to comment.