Commit 94143374 authored by Jay Darnell's avatar Jay Darnell Committed by micropat
Browse files

Issue #3208011 by JayDarnell: AddToAny block should work for all pages (not just nodes)

parent a4bc6efd
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -24,12 +24,17 @@ class AddToAnyBlock extends BlockBase {
    $node = \Drupal::routeMatch()->getParameter('node');
    if (is_numeric($node)) {
      $node = Node::load($node);
    }

      if ($node instanceof NodeInterface) {
        $data = addtoany_create_entity_data($node);
      }
    }
    else {
      $data = addtoany_create_data();
    }

    $build = [
        '#addtoany_html'              => \Drupal::token()->replace($data['addtoany_html'], ['node' => $node]),
      '#addtoany_html'              => $data['addtoany_html'],
      '#link_url'                   => $data['link_url'],
      '#link_title'                 => $data['link_title'],
      '#button_setting'             => $data['button_setting'],
@@ -41,6 +46,9 @@ class AddToAnyBlock extends BlockBase {
        'contexts' => ['url'],
      ],
    ];

    if ($node instanceof NodeInterface) {
      $build['#addtoany_html'] = \Drupal::token()->replace($data['addtoany_html'], ['node' => $node]);
    }

    return $build;