Skip to content

Commit 2a30d8d

Browse files
mglamanNiklan
andauthored
Add support for shorthand service definition syntax (#819)
Add support for shorthand service definition syntax (#817) * Allow interfaces to also be used as a 'class' in service definitions * Handle shorthand syntax for service definition Co-authored-by: Nikita Malyshev <[email protected]>
1 parent bbb92de commit 2a30d8d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Drupal/DrupalAutoloader.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ public function register(Container $container): void
226226
}
227227
});
228228
}
229+
// Handle shorthand syntax for service definition:
230+
// @code
231+
// Drupal\foo\FooService: {}
232+
// Drupal\foo\BarService:
233+
// tags:
234+
// - { name: foo_bar }
235+
// @endcode
236+
if (!isset($serviceDefinition['class']) && class_exists($serviceId)) {
237+
$serviceDefinition['class'] = $serviceId;
238+
}
229239
// @todo sanitize "calls" and "configurator" and "factory"
230240
/**
231241
jsonapi.params.enhancer:

0 commit comments

Comments
 (0)