Skip to content
Snippets Groups Projects
Commit 97969786 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1858054 by tim.plunkett, dawehner: Remove ViewExecutable::cloneView().

parent c437f67d
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\display;
use Drupal\views\ViewExecutable;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
......@@ -230,7 +231,7 @@ public function submitOptionsForm(&$form, &$form_state) {
/**
* Attach to another view.
*/
public function attachTo($display_id) {
public function attachTo(ViewExecutable $view, $display_id) {
$displays = $this->getOption('displays');
if (empty($displays[$display_id])) {
......@@ -241,10 +242,6 @@ public function attachTo($display_id) {
return;
}
// Get a fresh view because our current one has a lot of stuff on it because it's
// already been executed.
$view = $this->view->cloneView();
$args = $this->getOption('inherit_arguments') ? $this->view->args : array();
$view->setArguments($args);
$view->setDisplay($this->display['id']);
......
......@@ -380,7 +380,7 @@ public function usesAreas() {
/**
* Allow displays to attach to other views.
*/
public function attachTo($display_id) { }
public function attachTo(ViewExecutable $view, $display_id) { }
/**
* Static member function to list which sections are defaultable
......
......@@ -244,7 +244,7 @@ public function submitOptionsForm(&$form, &$form_state) {
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::attachTo().
*/
public function attachTo($display_id) {
public function attachTo(ViewExecutable $clone, $display_id) {
$displays = $this->getOption('displays');
if (empty($displays[$display_id])) {
return;
......@@ -254,7 +254,6 @@ public function attachTo($display_id) {
// attach a feed icon.
$plugin = $this->getPlugin('style');
if ($plugin) {
$clone = $this->view->cloneView();
$clone->setDisplay($this->display['id']);
$clone->buildTitle();
$plugin->attach_to($display_id, $this->getPath(), $clone->getTitle());
......
......@@ -1492,7 +1492,9 @@ public function attachDisplays() {
// Give other displays an opportunity to attach to the view.
foreach ($this->displayHandlers as $id => $display) {
if (!empty($this->displayHandlers[$id])) {
$this->displayHandlers[$id]->attachTo($this->current_display);
// Create a clone for the attachments to manipulate. 'static' refers to the current class name.
$cloned_view = new static($this->storage);
$this->displayHandlers[$id]->attachTo($cloned_view, $this->current_display);
}
}
$this->is_attachment = FALSE;
......@@ -1831,21 +1833,6 @@ public function createDuplicate() {
return entity_create('view', $data);
}
/**
* Safely clone a view.
*
* This will completely wipe a view clean so it can be considered fresh.
*
* @return Drupal\views\ViewExecutable
* The cloned view.
*/
public function cloneView() {
$storage = clone $this->storage;
$executable = new ViewExecutable($storage);
$storage->set('executable', $executable);
return $executable;
}
/**
* Unset references so that a $view object may be properly garbage
* collected.
......
......@@ -479,11 +479,6 @@ function views_menu_alter(&$callbacks) {
$our_paths[$path] = TRUE;
}
}
}
// Save memory: Destroy those views.
foreach ($views as $data) {
list($view, $display_id) = $data;
$view->destroy();
}
}
......@@ -1411,21 +1406,12 @@ function views_get_applicable_views($type) {
continue;
}
// Loop on array keys because something seems to muck with $view->display
// a bit in PHP4.
foreach (array_keys($display) as $id) {
$plugin = drupal_container()->get('plugin.manager.views.display')->getDefinition($display[$id]['display_plugin']);
if (!empty($plugin[$type])) {
// This view uses_hook_menu. Clone it so that different handlers
// don't trip over each other, and add it to the list.
$v = $view->get('executable')->cloneView();
if ($v->setDisplay($id) && $v->display_handler->isEnabled()) {
$result[] = array($v, $id);
}
// In PHP 4.4.7 and presumably earlier, if we do not unset $v
// here, we will find that it actually overwrites references
// possibly due to shallow copying issues.
unset($v);
// Check each display to see if it meets the criteria and is enabled.
$executable = $view->get('executable');
$executable->setDisplay();
foreach ($executable->displayHandlers as $id => $handler) {
if (!empty($handler->definition[$type]) && $handler->isEnabled()) {
$result[] = array($executable, $id);
}
}
}
......
......@@ -1460,8 +1460,7 @@ function views_ui_config_item_form($form, &$form_state) {
// We want this relationship option to get saved even if the user
// skips submitting the form.
$executable->setItemOption($display_id, $type, $id, 'relationship', $rel);
$temp_view = $view->cloneView();
views_ui_cache_set($temp_view);
views_ui_cache_set($view);
}
$form['options']['relationship'] = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment