- Issue created by @godotislate
As the use of service closures becomes more widely adopted in order load services lazily, there is a concern about how to make service closure properties type safe.
One proposed way to do this is to use property hooks starting with Drupal 12, once PHP 8.4 becomes the minimum requirement. For example:
class NodeThemeHooks {
protected FormBuilderInterface $formBuilder {
get => ($this->formBuilderClosure)();
}
public function __construct(
protected readonly RouteMatchInterface $routeMatch,
protected readonly RendererInterface $renderer,
protected readonly EntityTypeManagerInterface $entityTypeManager,
#[AutowireServiceClosure('form_builder')]
protected readonly \Closure $formBuilderClosure,
) { }
}
Active
11.0 🔥
base system