function ViewExecutable::__wakeup

Same name in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::__wakeup()
  2. 8.9.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::__wakeup()
  3. 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::__wakeup()

Magic method implementation to unserialize the view executable.

File

core/modules/views/src/ViewExecutable.php, line 2559

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function __wakeup() {
    // There are cases, like in testing where we don't have a container
    // available.
    if (\Drupal::hasContainer() && !empty($this->serializationData)) {
        // Load and reference the storage.
        $this->storage = \Drupal::entityTypeManager()->getStorage('view')
            ->load($this->serializationData['storage']);
        $this->storage
            ->set('executable', $this);
        // Attach all necessary services.
        $this->user = \Drupal::currentUser();
        $this->viewsData = \Drupal::service('views.views_data');
        $this->routeProvider = \Drupal::service('router.route_provider');
        $this->displayPluginManager = \Drupal::service('plugin.manager.views.display');
        // Restore the state of this executable.
        if ($request = \Drupal::request()) {
            $this->setRequest($request);
        }
        $this->setDisplay($this->serializationData['current_display']);
        $this->setArguments($this->serializationData['args']);
        $this->setCurrentPage($this->serializationData['current_page']);
        $this->setExposedInput($this->serializationData['exposed_input']);
        $this->exposed_data = $this->serializationData['exposed_data'];
        $this->exposed_raw_input = $this->serializationData['exposed_raw_input'];
        $this->dom_id = $this->serializationData['dom_id'];
        $this->initHandlers();
        // If the display was previously executed, execute it now.
        if ($this->serializationData['executed']) {
            $this->execute($this->current_display);
        }
    }
    // Unset serializationData since it serves no further purpose.
    unset($this->serializationData);
}

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