checkUrlAccess example

public function query() {
    if ($this->languageManager->isMultilingual()) {
      $this->getEntityTranslationRenderer()->query($this->query, $this->relationship);
    }
    $this->addAdditionalFields();
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $row) {
    $access = $this->checkUrlAccess($row);
    if ($access) {
      $build = ['#markup' => $access->isAllowed() ? $this->renderLink($row) : ''];
      BubbleableMetadata::createFromObject($access)->applyTo($build);
      return $build;
    }
    return '';
  }

  /** * Checks access to the link route. * * @param \Drupal\views\ResultRow $row * A view result row. * * @return \Drupal\Core\Access\AccessResultInterface|null * The access result, or NULL if the URI elements of the link doesn't exist. */
Home | Imprint | This part of the site doesn't use cookies.