You are here

public function ViewExecutable::destroy in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::destroy()

Unset references so that a $view object may be properly garbage collected.

File

core/modules/views/src/ViewExecutable.php, line 1924
Contains \Drupal\views\ViewExecutable.

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function destroy() {
  foreach ($this::getHandlerTypes() as $type => $info) {
    if (isset($this->{$type})) {
      foreach ($this->{$type} as $handler) {
        $handler
          ->destroy();
      }
    }
  }
  if (isset($this->style_plugin)) {
    $this->style_plugin
      ->destroy();
  }
  $reflection = new \ReflectionClass($this);
  $defaults = $reflection
    ->getDefaultProperties();

  // The external dependencies should not be reset. This is not generated by
  // the execution of a view.
  unset($defaults['storage'], $defaults['user'], $defaults['request'], $defaults['routeProvider']);
  foreach ($defaults as $property => $default) {
    $this->{$property} = $default;
  }
}