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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fabpot’s picture

Status: Active » Needs review
fabpot’s picture

Issue summary: View changes

updated description

Status: Needs review » Needs work

The last submitted patch, kernel_registration.patch, failed testing.

fabpot’s picture

Title: The kernel service should be available to other services » Added some missing synthetic services that were missing
Status: Needs work » Needs review
FileSize
1.05 KB
fabpot’s picture

Issue summary: View changes

tweaked description

aspilicious’s picture

Makes sense

Crell’s picture

I think some of those are already registered elsewhere in CoreBundle or drupal_container(), aren't they? I'm sure request is there somewhere...

Crell’s picture

Tagging

fabpot’s picture

FileSize
1.69 KB

You are right. I've just uploaded a new patch where synthetic services are registered in CoreBundle (which probably makes more sense).

chx’s picture

Status: Needs review » Needs work

I 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);.

katbailey’s picture

Actually 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.

fabpot’s picture

Status: Needs work » Needs review
FileSize
1.12 KB

The new patch takes into account the comments.

katbailey’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated the description to better explain the problem.