Loading src/Plugin/Block/AddToAnyBlock.php +8 −13 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ use Drupal\Core\Block\BlockBase; use Drupal\Core\Form\FormStateInterface; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\Core\Cache\Cache; /** * Provides an 'AddToAny share' block. Loading @@ -14,6 +13,9 @@ use Drupal\Core\Cache\Cache; * @Block( * id = "addtoany_block", * admin_label = @Translation("AddToAny share buttons"), * context_definitions = { * "node" = @ContextDefinition("entity:node", required = FALSE, label = @Translation("Node")) * } * ) */ class AddToAnyBlock extends BlockBase { Loading @@ -33,12 +35,9 @@ class AddToAnyBlock extends BlockBase { */ public function build() { $build = []; $node_id = \Drupal::routeMatch()->getParameter('node'); if (is_numeric($node_id)) { $node = Node::load($node_id); } $node = $this->getContextValue('node'); $is_node = isset($node) && $node instanceof NodeInterface ? TRUE : FALSE; $is_node = ($node instanceof NodeInterface); $data = $is_node ? addtoany_create_entity_data($node) : addtoany_create_data(); $block_options = []; Loading @@ -55,6 +54,9 @@ class AddToAnyBlock extends BlockBase { '#universal_button_placement' => $data['universal_button_placement'], '#buttons_size' => $block_options['buttons_size'], '#theme' => 'addtoany_standard', '#cache' => [ 'contexts' => ['url'], ], ]; if ($is_node) { Loading Loading @@ -152,11 +154,4 @@ class AddToAnyBlock extends BlockBase { } } /** * {@inheritdoc} */ public function getCacheContexts() { return Cache::mergeContexts(parent::getCacheContexts(), ['url']); } } Loading
src/Plugin/Block/AddToAnyBlock.php +8 −13 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ use Drupal\Core\Block\BlockBase; use Drupal\Core\Form\FormStateInterface; use Drupal\node\Entity\Node; use Drupal\node\NodeInterface; use Drupal\Core\Cache\Cache; /** * Provides an 'AddToAny share' block. Loading @@ -14,6 +13,9 @@ use Drupal\Core\Cache\Cache; * @Block( * id = "addtoany_block", * admin_label = @Translation("AddToAny share buttons"), * context_definitions = { * "node" = @ContextDefinition("entity:node", required = FALSE, label = @Translation("Node")) * } * ) */ class AddToAnyBlock extends BlockBase { Loading @@ -33,12 +35,9 @@ class AddToAnyBlock extends BlockBase { */ public function build() { $build = []; $node_id = \Drupal::routeMatch()->getParameter('node'); if (is_numeric($node_id)) { $node = Node::load($node_id); } $node = $this->getContextValue('node'); $is_node = isset($node) && $node instanceof NodeInterface ? TRUE : FALSE; $is_node = ($node instanceof NodeInterface); $data = $is_node ? addtoany_create_entity_data($node) : addtoany_create_data(); $block_options = []; Loading @@ -55,6 +54,9 @@ class AddToAnyBlock extends BlockBase { '#universal_button_placement' => $data['universal_button_placement'], '#buttons_size' => $block_options['buttons_size'], '#theme' => 'addtoany_standard', '#cache' => [ 'contexts' => ['url'], ], ]; if ($is_node) { Loading Loading @@ -152,11 +154,4 @@ class AddToAnyBlock extends BlockBase { } } /** * {@inheritdoc} */ public function getCacheContexts() { return Cache::mergeContexts(parent::getCacheContexts(), ['url']); } }