Skip to content

Commit d30fbd7

Browse files
authored
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
1 parent 6fab291 commit d30fbd7

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
@@ -225,6 +225,16 @@ public function register(Container $container): void
225225
}
226226
});
227227
}
228+
// Handle shorthand syntax for service definition:
229+
// @code
230+
// Drupal\foo\FooService: {}
231+
// Drupal\foo\BarService:
232+
// tags:
233+
// - { name: foo_bar }
234+
// @endcode
235+
if (!isset($serviceDefinition['class']) && class_exists($serviceId)) {
236+
$serviceDefinition['class'] = $serviceId;
237+
}
228238
// @todo sanitize "calls" and "configurator" and "factory"
229239
/**
230240
jsonapi.params.enhancer:

0 commit comments

Comments
 (0)