Skip to content

Instantly share code, notes, and snippets.

@chx

chx/-

Last active November 27, 2018 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chx/0832625f9ae14b113824729edf5bbe7a to your computer and use it in GitHub Desktop.
Save chx/0832625f9ae14b113824729edf5bbe7a to your computer and use it in GitHub Desktop.
diff --git a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
index d7088eb7b..45d4d7f1f 100644
--- a/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
+++ b/core/modules/node/src/Plugin/views/wizard/NodeRevision.php
@@ -2,6 +2,7 @@
namespace Drupal\node\Plugin\views\wizard;
+use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
/**
@@ -95,4 +96,42 @@ protected function defaultDisplayOptions() {
return $display_options;
}
+ protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) {
+ $filters = [];
+
+ if (($type = $form_state->getValue(['show', 'type'])) && $type != 'all') {
+ $filters['type'] = [
+ 'id' => 'type',
+ 'table' => 'node_field_data',
+ 'field' => 'type',
+ 'relationship' => 'nid',
+ 'value' => [$type => $type],
+ 'entity_type' => 'node',
+ 'entity_field' => 'type',
+ 'plugin_id' => 'bundle',
+ ];
+ }
+ return $filters;
+ }
+
+ protected function buildDisplayOptions($form, FormStateInterface $form_state) {
+ $display_options = parent::buildDisplayOptions($form, $form_state);
+ if (isset($display_options['default']['filters']['type'])) {
+ $display_options['default']['relationships']['nid'] = [
+ 'id' => 'nid',
+ 'table' => 'node_field_revision',
+ 'field' => 'nid',
+ 'relationship' => 'none',
+ 'group_type' => 'group',
+ 'admin_label' => 'Get the actual content from a content revision.',
+ 'required' => 'true',
+ 'entity_type' => 'node',
+ 'entity_field' => 'nid',
+ 'plugin_id' => 'standard',
+ ];
+ }
+ return $display_options;
+ }
+
+
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment