Loading src/Plugin/Block/AddToAnyBlock.php +7 −11 Original line number Diff line number Diff line Loading @@ -21,18 +21,14 @@ class AddToAnyBlock extends BlockBase { */ public function build() { $build = []; $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(); $node_id = \Drupal::routeMatch()->getParameter('node'); if (is_numeric($node_id)) { $node = Node::load($node_id); } $is_node = isset($node) && $node instanceof NodeInterface ? true : false; $data = $is_node ? addtoany_create_entity_data($node) : addtoany_create_data(); $build = [ '#addtoany_html' => $data['addtoany_html'], '#link_url' => $data['link_url'], Loading @@ -47,7 +43,7 @@ class AddToAnyBlock extends BlockBase { ], ]; if ($node instanceof NodeInterface) { if ($is_node) { $build['#addtoany_html'] = \Drupal::token()->replace($data['addtoany_html'], ['node' => $node]); } Loading Loading
src/Plugin/Block/AddToAnyBlock.php +7 −11 Original line number Diff line number Diff line Loading @@ -21,18 +21,14 @@ class AddToAnyBlock extends BlockBase { */ public function build() { $build = []; $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(); $node_id = \Drupal::routeMatch()->getParameter('node'); if (is_numeric($node_id)) { $node = Node::load($node_id); } $is_node = isset($node) && $node instanceof NodeInterface ? true : false; $data = $is_node ? addtoany_create_entity_data($node) : addtoany_create_data(); $build = [ '#addtoany_html' => $data['addtoany_html'], '#link_url' => $data['link_url'], Loading @@ -47,7 +43,7 @@ class AddToAnyBlock extends BlockBase { ], ]; if ($node instanceof NodeInterface) { if ($is_node) { $build['#addtoany_html'] = \Drupal::token()->replace($data['addtoany_html'], ['node' => $node]); } Loading