+ /**
+ * {@inheritdoc}
+ */
+ public function access() {
+ // Mark the widget as not visible if the user has no access to the view.
+ /** @var \Drupal\views\ViewExecutable $view */
+ $view = $this->entityTypeManager
+ ->getStorage('view')
+ ->load($this->configuration['view'])
+ ->getExecutable();
+
+
+ // Check if the current user has access to this view.
+ return AccessResult::allowedIf($view->access($this->configuration['view_display']));
+ }
+