Skip to content

Commit

Permalink
Add support for shorthand service definition syntax (#819)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mglaman and Niklan authored Jan 23, 2025
1 parent bbb92de commit 2a30d8d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Drupal/DrupalAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ public function register(Container $container): void
}
});
}
// Handle shorthand syntax for service definition:
// @code
// Drupal\foo\FooService: {}
// Drupal\foo\BarService:
// tags:
// - { name: foo_bar }
// @endcode
if (!isset($serviceDefinition['class']) && class_exists($serviceId)) {
$serviceDefinition['class'] = $serviceId;
}
// @todo sanitize "calls" and "configurator" and "factory"
/**
jsonapi.params.enhancer:
Expand Down

0 comments on commit 2a30d8d

Please sign in to comment.