diff --git a/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php index 72f754b..ed9f5c0 100644 --- a/core/modules/views/src/Form/ViewsExposedForm.php +++ b/core/modules/views/src/Form/ViewsExposedForm.php @@ -120,7 +120,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#id'] = Html::cleanCssIdentifier('views_exposed_form-' . String::checkPlain($view->storage->id()) . '-' . String::checkPlain($display['id'])); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ - $exposed_form_plugin = $form_state->get('exposed_form_plugin'); + $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form'); $exposed_form_plugin->exposedFormAlter($form, $form_state); // Save the form. @@ -133,15 +133,17 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { + $view = $form_state->get('view'); + foreach (array('field', 'filter') as $type) { /** @var \Drupal\views\Plugin\views\ViewsHandlerInterface[] $handlers */ - $handlers = &$form_state->get('view')->$type; + $handlers = &$view->$type; foreach ($handlers as $key => $handler) { $handlers[$key]->validateExposed($form, $form_state); } } /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ - $exposed_form_plugin = $form_state->get('exposed_form_plugin'); + $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form'); $exposed_form_plugin->exposedFormValidate($form, $form_state); } @@ -156,13 +158,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $handlers[$key]->submitExposed($form, $form_state); } } + $view = $form_state->get('view'); $view->exposed_data = $form_state->getValues(); $view->exposed_raw_input = []; - $exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', '', 'reset'); + $exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', 'reset'); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */ - $exposed_form_plugin = $form_state->get('exposed_form_plugin'); + $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form'); $exposed_form_plugin->exposedFormSubmit($form, $form_state, $exclude); foreach ($form_state->getValues() as $key => $value) { diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 3652e8b..16f86a8 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -150,7 +150,6 @@ public function renderExposedForm($block = FALSE) { $form_state->set('ajax', TRUE); } - $form_state->set('exposed_form_plugin', $this); $form = \Drupal::formBuilder()->buildForm('\Drupal\views\Form\ViewsExposedForm', $form_state); if (!$this->view->display_handler->displaysExposed() || (!$block && $this->view->display_handler->getOption('exposed_block'))) { diff --git a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php index bb6b803..34a2a9a 100644 --- a/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php +++ b/core/modules/views/src/Plugin/views/relationship/RelationshipPluginBase.php @@ -55,6 +55,13 @@ abstract class RelationshipPluginBase extends HandlerBase { /** + * The relationship alias. + * + * @var string + */ + public $alias; + + /** * Overrides \Drupal\views\Plugin\views\HandlerBase::init(). * * Init handler to let relationships live on tables other than diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 9791a88..6484a61 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -15,6 +15,7 @@ use Drupal\views\Plugin\views\query\QueryPluginBase; use Drupal\views\ViewEntityInterface; use Drupal\Component\Utility\Tags; +use Drupal\views_ui\ViewUI; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -24,7 +25,7 @@ * 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. */ -class ViewExecutable { +class ViewExecutable implements \Serializable { use DependencySerializationTrait; /** @@ -2231,4 +2232,49 @@ public function calculateDependencies() { return $this->storage->calculateDependencies(); } + /** + * {@inheritdoc} + */ + public function serialize() { + $storage = $this->storage instanceof ViewUI ? $this->storage : $this->storage->id(); + return serialize([ + $storage, + $this->current_display, + $this->args, + $this->current_page, + $this->exposed_input, + $this->exposed_raw_input, + $this->exposed_data, + $this->dom_id, + $this->executed, + ]); + } + + /** + * {@inheritdoc} + */ + public function unserialize($serialized) { + list($storage, $current_display, $args, $current_page, $exposed_input, $exposed_raw_input, $exposed_data, $dom_id, $executed) = unserialize($serialized); + + $this->setRequest(\Drupal::request()); + $this->user = \Drupal::currentUser(); + + $this->storage = is_object($storage) ? $storage : \Drupal::entityManager()->getStorage('view')->load($storage); + + $this->setDisplay($current_display); + $this->setArguments($args); + $this->setCurrentPage($current_page); + $this->setExposedInput($exposed_input); + $this->exposed_data = $exposed_data; + $this->exposed_raw_input = $exposed_raw_input; + $this->dom_id = $dom_id; + + $this->initHandlers(); + + // If the display was previously executed, execute it now. + if ($executed) { + $this->execute($this->current_display); + } + } + } diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 08e887c..3b5351b 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -171,6 +171,7 @@ class ViewUI implements ViewEntityInterface { public function __construct(ViewEntityInterface $storage, ViewExecutable $executable = NULL) { $this->entityType = 'view'; $this->storage = $storage; + if (!isset($executable)) { $executable = Views::executableFactory()->get($this); } @@ -869,14 +870,14 @@ public function cacheSet() { if (isset($executable->current_display)) { // Add the knowledge of the changed display, too. $this->changed_display[$executable->current_display] = TRUE; - unset($executable->current_display); + $executable->current_display = NULL; } - // Unset handlers; we don't want to write these into the cache. - unset($executable->display_handler); - unset($executable->default_display); + // Unset handlers. We don't want to write these into the cache. + $executable->display_handler = NULL; + $executable->default_display = NULL; $executable->query = NULL; - unset($executable->displayHandlers); + $executable->displayHandlers = NULL; \Drupal::service('user.tempstore')->get('views')->set($this->id(), $this); } @@ -1128,7 +1129,7 @@ public static function postLoad(EntityStorageInterface $storage, array &$entitie * {@inheritdoc} */ public function getExecutable() { - return $this->storage->getExecutable(); + return $this->executable; } /** @@ -1234,11 +1235,4 @@ public function getTypedData() { public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { return $this->storage->addDisplay($plugin_id, $title, $id); } - - /** - * {@inheritdoc} - */ - public function getViewExecutable() { - return $this->storage->getViewExecutable(); - } }