summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsamuel.mortenson2017-04-27 18:18:48 -0700
committerPat Diven II2017-04-27 18:18:48 -0700
commitff9c059ff1c723b28c981ae6e00a56d398705681 (patch)
tree52a4abb77f5b73a2d89ba3daa858dc482c456670
parentccb159ad782a2a50ab59e7acb0a978f49e34817a (diff)
Issue #2855283 by samuel.mortenson: Error while viewing a history revision8.x-1.8
-rw-r--r--addtoany.module7
-rw-r--r--src/Plugin/Block/AddToAnyBlock.php5
2 files changed, 11 insertions, 1 deletions
diff --git a/addtoany.module b/addtoany.module
index 8b00a6a..a601800 100644
--- a/addtoany.module
+++ b/addtoany.module
@@ -11,6 +11,7 @@ use Drupal\Core\Url;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\UrlHelper;
use Drupal\node\Entity\NodeType;
+use Drupal\node\Entity\Node;
/**
* Implements hook_theme().
@@ -77,6 +78,9 @@ function addtoany_page_attachments(&$page) {
$node = \Drupal::routeMatch()->getParameter('node');
$data = [];
if ($node) {
+ if (is_numeric($node)) {
+ $node = Node::load($node);
+ }
$data = ['node' => $node];
$additional_js = \Drupal::token()->replace($additional_js, $data);
}
@@ -254,6 +258,9 @@ function addtoany_create_buttons($url = NULL, $title = NULL, $config = NULL) {
$node = \Drupal::routeMatch()->getParameter('node');
$data = [];
if ($node) {
+ if (is_numeric($node)) {
+ $node = Node::load($node);
+ }
$data = ['node' => $node];
$buttons = \Drupal::token()->replace($buttons, $data);
}
diff --git a/src/Plugin/Block/AddToAnyBlock.php b/src/Plugin/Block/AddToAnyBlock.php
index 41b07c9..47e611a 100644
--- a/src/Plugin/Block/AddToAnyBlock.php
+++ b/src/Plugin/Block/AddToAnyBlock.php
@@ -3,6 +3,7 @@
namespace Drupal\addtoany\Plugin\Block;
use Drupal\Core\Block\BlockBase;
+use Drupal\node\Entity\Node;
/**
* Provides an 'AddToAny' block.
@@ -19,7 +20,9 @@ class AddToAnyBlock extends BlockBase {
*/
public function build() {
$node = \Drupal::routeMatch()->getParameter('node');
-
+ if (is_numeric($node)) {
+ $node = Node::load($node);
+ }
return array(
'#addtoany_html' => addtoany_create_node_buttons($node),
'#theme' => 'addtoany_standard',