Loading src/Plugin/views/filter/EntityReference.php +24 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @ViewsFilter("verf") */ class EntityReference extends InOperator implements ContainerFactoryPluginInterface { class EntityReference extends InOperator implements ContainerFactoryPluginInterface { /** * The entity type bundle info. Loading Loading @@ -108,6 +109,10 @@ class EntityReference extends InOperator implements ContainerFactoryPluginInterf 'default' => [], ]; $options['show_unpublished'] = [ 'default' => FALSE, ]; return $options; } Loading @@ -116,6 +121,13 @@ class EntityReference extends InOperator implements ContainerFactoryPluginInterf */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['show_unpublished'] = [ '#type' => 'checkbox', '#title' => t("Ignore access control"), '#default_value' => $this->options['show_unpublished'], ]; if (!$this->targetEntityType->hasKey('bundle')) { return $form; } Loading Loading @@ -197,6 +209,17 @@ class EntityReference extends InOperator implements ContainerFactoryPluginInterf } $this->referenceableEntities = $this->targetEntityStorage->loadMultiple($target_ids); if (!$this->options['show_unpublished']) { $filtered_target_ids = []; foreach ($this->referenceableEntities as $entity) { if ($entity->access('view')) { $filtered_target_ids[] = $entity; } } $this->referenceableEntities = $filtered_target_ids; } return $this->referenceableEntities; } Loading Loading
src/Plugin/views/filter/EntityReference.php +24 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @ViewsFilter("verf") */ class EntityReference extends InOperator implements ContainerFactoryPluginInterface { class EntityReference extends InOperator implements ContainerFactoryPluginInterface { /** * The entity type bundle info. Loading Loading @@ -108,6 +109,10 @@ class EntityReference extends InOperator implements ContainerFactoryPluginInterf 'default' => [], ]; $options['show_unpublished'] = [ 'default' => FALSE, ]; return $options; } Loading @@ -116,6 +121,13 @@ class EntityReference extends InOperator implements ContainerFactoryPluginInterf */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['show_unpublished'] = [ '#type' => 'checkbox', '#title' => t("Ignore access control"), '#default_value' => $this->options['show_unpublished'], ]; if (!$this->targetEntityType->hasKey('bundle')) { return $form; } Loading Loading @@ -197,6 +209,17 @@ class EntityReference extends InOperator implements ContainerFactoryPluginInterf } $this->referenceableEntities = $this->targetEntityStorage->loadMultiple($target_ids); if (!$this->options['show_unpublished']) { $filtered_target_ids = []; foreach ($this->referenceableEntities as $entity) { if ($entity->access('view')) { $filtered_target_ids[] = $entity; } } $this->referenceableEntities = $filtered_target_ids; } return $this->referenceableEntities; } Loading