Conversion.
Closes #3414625
Merge request reports
Activity
43 39 * The event object. 44 40 */ 45 41 public function onKernelTerminate(TerminateEvent $event) { 46 foreach ($this->services as $id) { 47 // Check if the service was initialized during this request, destruction 48 // is not necessary if the service was not used. 49 if ($this->container->initialized($id)) { 50 $service = $this->container->get($id); 42 foreach ($this->services as $service) { configurators are neat way to track initialised on a per request basis.
do we have existing coverage to ensure that services not initialised [during a request] do not get called by this method? formerly, the
initialized
gate.we should add coverage to ensure the configurator in particular is, and is not, registered.
random q, is there any need to de-register the autoconfigurators in the same request? or will container reset/rebuilt do all we need
\Drupal\KernelTests\Core\DrupalKernel\ServiceDestructionTest claims to cover both cases, I haven't looked at it in detail or tried to break it, but it does still pass here.
We could perhaps add coverage to spy into the
$services
property and check that the services are correctly registered as well.Not really sure about de-registration, is there a case where the kernel is destructed twice? Maybe we should forget each service after we have called
destruct()
? But that seems more dangerous as I don't think the configurator will be called a second time.Edited by Dave Long