public function ViewExecutable::destroy

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

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 1696
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function destroy() {
  foreach ($this::viewsHandlerTypes() 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 storage should not be reset. This is not generated by the execution
  // of a view.
  unset($defaults['storage']);
  foreach ($defaults as $property => $default) {
    $this->{$property} = $default;
  }
}