setShowAdminLinks example

$event->addCacheableDependency($access);
    if ($access->isAllowed()) {
      $event->addCacheableDependency($block);

      // @todo Revisit after https://www.drupal.org/node/3027653, as this will       // provide a better way to remove contextual links from Views blocks.       // Currently, doing this requires setting       // \Drupal\views\ViewExecutable::$showAdminLinks() to false before the       // Views block is built.       if ($block instanceof ViewsBlock && $event->inPreview()) {
        $block->getViewExecutable()->setShowAdminLinks(FALSE);
      }

      $content = $block->build();

      // We don't output the block render data if there are no render elements       // found, but we want to capture the cache metadata from the block       // regardless.       $event->addCacheableDependency(CacheableMetadata::createFromRenderArray($content));

      $is_content_empty = Element::isEmpty($content);
      $is_placeholder_ready = $event->inPreview() && $block instanceof PreviewFallbackInterface;
      
Home | Imprint | This part of the site doesn't use cookies.