Skip to content

Commit

Permalink
Add support for shorthand service definition syntax (#817)
Browse files Browse the repository at this point in the history
* Allow interfaces to also be used as a 'class' in service definitions

* Handle shorthand syntax for service definition
  • Loading branch information
Niklan authored Jan 17, 2025
1 parent 6fab291 commit d30fbd7
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 @@ -225,6 +225,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 d30fbd7

Please sign in to comment.