function DrupalKernel::terminate

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

File

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

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

public function terminate(Request $request, Response $response) : void {
    if ($this->booted && $this->getHttpKernel() instanceof TerminableInterface) {
        // Only run terminate() when essential services have been set up properly
        // by preHandle() before.
        if ($this->prepared === TRUE) {
            $this->getHttpKernel()
                ->terminate($request, $response);
        }
        // For destructable services, always call the destruct method if they were
        // initialized during the request. Destruction is not necessary if the
        // service was not used.
        foreach ($this->container
            ->getParameter('kernel.destructable_services') as $id) {
            if ($this->container
                ->initialized($id)) {
                $service = $this->container
                    ->get($id);
                $service->destruct();
            }
        }
    }
}

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