Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Restorer.php

function Restorer::restoreGlobalVariables

File

vendor/sebastian/global-state/src/Restorer.php, line 23

Class

Restorer

Namespace

SebastianBergmann\GlobalState

Code

public function restoreGlobalVariables(Snapshot $snapshot) : void {
    $superGlobalArrays = $snapshot->superGlobalArrays();
    foreach ($superGlobalArrays as $superGlobalArray) {
        $this->restoreSuperGlobalArray($snapshot, $superGlobalArray);
    }
    $globalVariables = $snapshot->globalVariables();
    foreach (array_keys($GLOBALS) as $key) {
        if ($key !== 'GLOBALS' && !in_array($key, $superGlobalArrays, true) && !$snapshot->excludeList()
            ->isGlobalVariableExcluded($key)) {
            if (array_key_exists($key, $globalVariables)) {
                $GLOBALS[$key] = $globalVariables[$key];
            }
            else {
                unset($GLOBALS[$key]);
            }
        }
    }
}
RSS feed
Powered by Drupal