public function ViewExecutable::cloneView

Safely clone a view.

This will completely wipe a view clean so it can be considered fresh.

Return value

Drupal\views\ViewExecutable The cloned view.

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 1842
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 cloneView() {
  $storage = clone $this->storage;
  $executable = new ViewExecutable($storage);
  $storage
    ->set('executable', $executable);
  return $executable;
}