Unverified Commit 4b473042 authored by Alex Pott's avatar Alex Pott
Browse files

task: #3039248 Deprecate views_ui_contextual_links_suppress(),...

task: #3039248 Deprecate views_ui_contextual_links_suppress(), views_ui_contextual_links_suppress_push(), views_ui_contextual_links_suppress_pop()

By: andypost
By: naresh_bavaskar
By: hardik_patel_12
By: longwave
By: alex_optim
By: claudiu.cristea
By: nicxvan
By: berdir
(cherry picked from commit 3742821e)
parent 1ee7cb4e
Loading
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -92,12 +92,7 @@ public function viewsPluginsDisplayAlter(&$plugins): void {
   */
  #[Hook('contextual_links_view_alter')]
  public function contextualLinksViewAlter(&$element, $items): void {
    // Remove contextual links from being rendered, when so desired, such as
    // within a View preview.
    if (views_ui_contextual_links_suppress()) {
      $element['#links'] = [];
    }
    elseif (!empty($element['#links']['entityviewedit-form'])) {
    if (!empty($element['#links']['entityviewedit-form'])) {
      $display_id = $items['entity.view.edit_form']['metadata']['display_id'];
      $route_parameters = $element['#links']['entityviewedit-form']['url']->getRouteParameters() + ['display_id' => $display_id];
      $element['#links']['entityviewedit-form']['url'] = Url::fromRoute('entity.view.edit_display_form', $route_parameters);
+0 −9
Original line number Diff line number Diff line
@@ -611,13 +611,6 @@ public function renderPreview($display_id, $args = []) {
      $request->setSession($request_stack->getSession());
      $request_stack->push($request);

      // Suppress contextual links of entities within the result set during a
      // Preview.
      // @todo We'll want to add contextual links specific to editing the View,
      //   so the suppression may need to be moved deeper into the Preview
      //   pipeline.
      views_ui_contextual_links_suppress_push();

      $show_additional_queries = $config->get('ui.show.additional_queries');

      Timer::start('entity.view.preview_form');
@@ -635,8 +628,6 @@ public function renderPreview($display_id, $args = []) {

      $this->render_time = Timer::stop('entity.view.preview_form')['time'];

      views_ui_contextual_links_suppress_pop();

      // Prepare the query information and statistics to show either above or
      // below the view preview.
      // Initialize the empty rows arrays so we can safely merge them later.
+15 −10
Original line number Diff line number Diff line
@@ -98,14 +98,13 @@ function views_ui_view_preview_section_rows_links(ViewExecutable $view): array {
/**
 * Sets a static variable for controlling whether contextual links are rendered.
 *
 * @see views_ui_contextual_links_view_alter()
 * @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no
 *   replacement.
 *
 * @see https://www.drupal.org/node/3039250
 */
function views_ui_contextual_links_suppress($set = NULL) {
  $suppress = &drupal_static(__FUNCTION__);
  if (isset($set)) {
    $suppress = $set;
  }
  return $suppress;
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3039250', E_USER_DEPRECATED);
}

/**
@@ -118,19 +117,25 @@ function views_ui_contextual_links_suppress($set = NULL) {
 * during a View preview, when it is not desired for nodes in the Views result
 * to have contextual links.
 *
 * @see views_ui_contextual_links_suppress_pop()
 * @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no
 *   replacement.
 *
 * @see https://www.drupal.org/node/3039250
 */
function views_ui_contextual_links_suppress_push(): void {
  views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress()) + 1);
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3039250', E_USER_DEPRECATED);
}

/**
 * Decrements the views_ui_contextual_links_suppress() static variable.
 *
 * @see views_ui_contextual_links_suppress_push()
 * @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no
 *   replacement.
 *
 * @see https://www.drupal.org/node/3039250
 */
function views_ui_contextual_links_suppress_pop(): void {
  views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress()) - 1);
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3039250', E_USER_DEPRECATED);
}

/**