function DrupalKernel::getServicesToPersist

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getServicesToPersist()
  2. 8.9.x core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getServicesToPersist()
  3. 10 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getServicesToPersist()

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

2 calls to DrupalKernel::getServicesToPersist()
DrupalKernel::attachSynthetic in core/lib/Drupal/Core/DrupalKernel.php
Attach synthetic values on to kernel.
DrupalKernel::resetContainer in core/lib/Drupal/Core/DrupalKernel.php
Force a container reset.

File

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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.