diff --git a/Rate_D10_entity_query_with_access_list.patch b/Rate_D10_entity_query_with_access_list.patch new file mode 100644 index 0000000..d5f5c1c --- /dev/null +++ b/Rate_D10_entity_query_with_access_list.patch @@ -0,0 +1,103 @@ +diff --git a/src/Plugin/views/field/RateWidgetField.php b/src/Plugin/views/field/RateWidgetField.php +index a9da42c..6a78731 100644 +--- a/src/Plugin/views/field/RateWidgetField.php ++++ b/src/Plugin/views/field/RateWidgetField.php +@@ -49,8 +49,7 @@ class RateWidgetField extends FieldPluginBase { + if ($field_name['entity_type'] && $field_name['plugin_id'] != 'rate_widget_field') { + if (empty($field_name['label'])) { + $field_list[$field_name['id']] = $field_name['id']; +- } +- else { ++ } else { + $field_list[$field_name['id']] = $field_name['label']; + } + } +@@ -100,8 +99,7 @@ class RateWidgetField extends FieldPluginBase { + ]; + } + } +- } +- else { ++ } else { + $form['widgets'] = []; + } + // Select how to display the widget. +@@ -149,17 +147,13 @@ class RateWidgetField extends FieldPluginBase { + $entity_type_id = $row->_entity->getEntityTypeId(); + if ($entity_type_id == 'user' || $entity_type_id == 'comment' || $entity_type_id == 'file') { + $bundle = $entity_type_id; +- } +- elseif ($entity_type_id == 'group') { ++ } elseif ($entity_type_id == 'group') { + $bundle = $row->_entity->getGroupType()->id(); +- } +- elseif ($entity_type_id == 'group_content') { ++ } elseif ($entity_type_id == 'group_content') { + $bundle = $row->_entity->getGroupContentType()->id(); +- } +- elseif ($entity_type_id == 'taxonomy_term') { ++ } elseif ($entity_type_id == 'taxonomy_term') { + $bundle = $row->_entity->getVocabularyId(); +- } +- else { ++ } else { + $bundle = $row->_entity->bundle(); + } + } +@@ -172,17 +166,13 @@ class RateWidgetField extends FieldPluginBase { + $entity_type_id = $row->_relationship_entities[$rel]->getEntityTypeId(); + if ($entity_type_id == 'user' || $entity_type_id == 'comment') { + $bundle = $entity_type_id; +- } +- elseif ($entity_type_id == 'group') { ++ } elseif ($entity_type_id == 'group') { + $bundle = $row->_relationship_entities[$rel]->getGroupType()->id(); +- } +- elseif ($entity_type_id == 'group_content') { ++ } elseif ($entity_type_id == 'group_content') { + $bundle = $row->_relationship_entities[$rel]->getGroupContentType()->id(); +- } +- elseif ($entity_type_id == 'taxonomy_term') { ++ } elseif ($entity_type_id == 'taxonomy_term') { + $bundle = $row->_relationship_entities[$rel]->getVocabularyId(); +- } +- else { ++ } else { + $bundle = $row->_relationship_entities[$rel]->bundle(); + } + } +@@ -190,10 +180,9 @@ class RateWidgetField extends FieldPluginBase { + } + if (!isset($entity_id) || !isset($entity_type_id) || !isset($bundle)) { + return; +- } +- else { ++ } else { + // Get the widgets assigned to this entity. +- $query = \Drupal::entityQuery('rate_widget'); ++ $query = \Drupal::entityQuery('rate_widget')->accessCheck(TRUE); + $query->condition('entity_types.*', [$entity_type_id . '.' . $bundle], 'IN'); + $widget_ids = $query->execute(); + +@@ -207,13 +196,11 @@ class RateWidgetField extends FieldPluginBase { + $selected_widget = $widgets[$entity_type_id . ':' . $bundle]['widget']; + if (isset($selected_widget) && in_array($selected_widget, $widget_ids)) { + $widget = $selected_widget; +- } +- else { ++ } else { + // Get the first widget. + $widget = array_shift($widget_ids); + } +- } +- else { ++ } else { + // Get the first widget. + $widget = array_shift($widget_ids); + } +@@ -270,5 +257,4 @@ class RateWidgetField extends FieldPluginBase { + return $build; + } + } +- + } diff --git a/src/Plugin/views/field/RateWidgetField.php b/src/Plugin/views/field/RateWidgetField.php index a9da42c..6a78731 100644 --- a/src/Plugin/views/field/RateWidgetField.php +++ b/src/Plugin/views/field/RateWidgetField.php @@ -49,8 +49,7 @@ class RateWidgetField extends FieldPluginBase { if ($field_name['entity_type'] && $field_name['plugin_id'] != 'rate_widget_field') { if (empty($field_name['label'])) { $field_list[$field_name['id']] = $field_name['id']; - } - else { + } else { $field_list[$field_name['id']] = $field_name['label']; } } @@ -100,8 +99,7 @@ class RateWidgetField extends FieldPluginBase { ]; } } - } - else { + } else { $form['widgets'] = []; } // Select how to display the widget. @@ -149,17 +147,13 @@ class RateWidgetField extends FieldPluginBase { $entity_type_id = $row->_entity->getEntityTypeId(); if ($entity_type_id == 'user' || $entity_type_id == 'comment' || $entity_type_id == 'file') { $bundle = $entity_type_id; - } - elseif ($entity_type_id == 'group') { + } elseif ($entity_type_id == 'group') { $bundle = $row->_entity->getGroupType()->id(); - } - elseif ($entity_type_id == 'group_content') { + } elseif ($entity_type_id == 'group_content') { $bundle = $row->_entity->getGroupContentType()->id(); - } - elseif ($entity_type_id == 'taxonomy_term') { + } elseif ($entity_type_id == 'taxonomy_term') { $bundle = $row->_entity->getVocabularyId(); - } - else { + } else { $bundle = $row->_entity->bundle(); } } @@ -172,17 +166,13 @@ class RateWidgetField extends FieldPluginBase { $entity_type_id = $row->_relationship_entities[$rel]->getEntityTypeId(); if ($entity_type_id == 'user' || $entity_type_id == 'comment') { $bundle = $entity_type_id; - } - elseif ($entity_type_id == 'group') { + } elseif ($entity_type_id == 'group') { $bundle = $row->_relationship_entities[$rel]->getGroupType()->id(); - } - elseif ($entity_type_id == 'group_content') { + } elseif ($entity_type_id == 'group_content') { $bundle = $row->_relationship_entities[$rel]->getGroupContentType()->id(); - } - elseif ($entity_type_id == 'taxonomy_term') { + } elseif ($entity_type_id == 'taxonomy_term') { $bundle = $row->_relationship_entities[$rel]->getVocabularyId(); - } - else { + } else { $bundle = $row->_relationship_entities[$rel]->bundle(); } } @@ -190,10 +180,9 @@ class RateWidgetField extends FieldPluginBase { } if (!isset($entity_id) || !isset($entity_type_id) || !isset($bundle)) { return; - } - else { + } else { // Get the widgets assigned to this entity. - $query = \Drupal::entityQuery('rate_widget'); + $query = \Drupal::entityQuery('rate_widget')->accessCheck(TRUE); $query->condition('entity_types.*', [$entity_type_id . '.' . $bundle], 'IN'); $widget_ids = $query->execute(); @@ -207,13 +196,11 @@ class RateWidgetField extends FieldPluginBase { $selected_widget = $widgets[$entity_type_id . ':' . $bundle]['widget']; if (isset($selected_widget) && in_array($selected_widget, $widget_ids)) { $widget = $selected_widget; - } - else { + } else { // Get the first widget. $widget = array_shift($widget_ids); } - } - else { + } else { // Get the first widget. $widget = array_shift($widget_ids); } @@ -270,5 +257,4 @@ class RateWidgetField extends FieldPluginBase { return $build; } } - }