getShowAdminLinks example

    if (!empty($output)) {
      // Contextual links only work on blocks whose content is a renderable       // array, so if the block contains a string of already-rendered markup,       // convert it to an array.       if (is_string($output)) {
        $output = ['#markup' => $output];
      }

      // views_add_contextual_links() needs the following information in       // order to be attached to the view.       $output['#view_id'] = $this->view->storage->id();
      $output['#view_display_show_admin_links'] = $this->view->getShowAdminLinks();
      $output['#view_display_plugin_id'] = $this->view->display_handler->getPluginId();
      views_add_contextual_links($output$block_type$this->displayID);
    }
  }

  /** * Gets the view executable. * * @return \Drupal\views\ViewExecutable * The view executable. * * @todo revisit after https://www.drupal.org/node/3027653. This method was * added in https://www.drupal.org/node/3002608, but should not be * necessary once block plugins can determine if they are being previewed. */
        // a #pre_render callback.         $element['view_build'] = $view->executeDisplay($element['#display_id']$element['#arguments']);

        if (isset($element['view_build']['#title'])) {
          $element['#title'] = &$element['view_build']['#title'];
        }

        if (empty($view->display_handler->getPluginDefinition()['returns_response'])) {
          // views_add_contextual_links() needs the following information in           // order to be attached to the view.           $element['#view_id'] = $view->storage->id();
          $element['#view_display_show_admin_links'] = $view->getShowAdminLinks();
          $element['#view_display_plugin_id'] = $view->display_handler->getPluginId();
          views_add_contextual_links($element, 'view', $view->current_display);
        }
      }
      if (empty($view->display_handler->getPluginDefinition()['returns_response'])) {
        $element['#attributes']['class'][] = 'views-element-container';
        $element['#theme_wrappers'] = ['container'];
      }
    }

    return $element;
  }
Home | Imprint | This part of the site doesn't use cookies.