Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When creating some third-party Drupal modules, it is possible to register some new services. But if a service depends on the kernel, the request, or the service_container, it won't work as they are not declared as synthetic and they are not yet available when building the container.
Proposed resolution
This patch registers these missing synthetic services.
Comment | File | Size | Author |
---|---|---|---|
#10 | kernel_registration_10.patch | 1.12 KB | fabpot |
#7 | kernel_registration_7.patch | 1.69 KB | fabpot |
#3 | kernel_registration_3.patch | 1.05 KB | fabpot |
kernel_registration.patch | 1.03 KB | fabpot | |
Comments
Comment #1
fabpot CreditAttribution: fabpot commentedComment #1.0
fabpot CreditAttribution: fabpot commentedupdated description
Comment #3
fabpot CreditAttribution: fabpot commentedComment #3.0
fabpot CreditAttribution: fabpot commentedtweaked description
Comment #4
aspilicious CreditAttribution: aspilicious commentedMakes sense
Comment #5
Crell CreditAttribution: Crell commentedI think some of those are already registered elsewhere in CoreBundle or drupal_container(), aren't they? I'm sure request is there somewhere...
Comment #6
Crell CreditAttribution: Crell commentedTagging
Comment #7
fabpot CreditAttribution: fabpot commentedYou are right. I've just uploaded a new patch where synthetic services are registered in
CoreBundle
(which probably makes more sense).Comment #8
chx CreditAttribution: chx commentedI will be audacious and set a fabpot patch to CNW :) but it misses the classes from the registration. It's much nicer to register with a class because then it's documented in the compiled container, IDE integration whatnot.
Ie. compare the removed
$container->register('class_loader', 'Symfony\Component\ClassLoader\UniversalClassLoader')->setSynthetic(TRUE);
to$container->register('class_loader')->setSynthetic(TRUE);
.Comment #9
katbailey CreditAttribution: katbailey commentedActually DrupalKernel seems to me like a better place for the 'kernel', 'service_container' and 'class_loader' services because each of them will get set (either by the kernel itself or by the container in the case of service_container) regardless of what happens in CoreBundle.
Comment #10
fabpot CreditAttribution: fabpot commentedThe new patch takes into account the comments.
Comment #11
katbailey CreditAttribution: katbailey commentedLooks good to me.
Comment #12
webchickCommitted and pushed to 8.x. Thanks!
Comment #13.0
(not verified) CreditAttribution: commentedUpdated the description to better explain the problem.