You are here

protected function DrupalKernel::getServicesToPersist in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getServicesToPersist()

Returns service instances to persist from an old container to a new one.

1 call to DrupalKernel::getServicesToPersist()
DrupalKernel::attachSynthetic in core/lib/Drupal/Core/DrupalKernel.php
Attach synthetic values on to kernel.

File

core/lib/Drupal/Core/DrupalKernel.php, line 1119

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected function getServicesToPersist(ContainerInterface $container) {
  $persist = [];
  foreach ($container
    ->getParameter('persist_ids') as $id) {

    // It's pointless to persist services not yet initialized.
    if ($container
      ->initialized($id)) {
      $persist[$id] = $container
        ->get($id);
    }
  }
  return $persist;
}