From 5b9e61d7e15f4876dd380fb223adb643c3cc1f24 Mon Sep 17 00:00:00 2001
From: rudiedirkx <rudiedirkx@890274.no-reply.drupal.org>
Date: Sat, 25 Jun 2016 10:29:14 +0200
Subject: [PATCH] Issue #2442205 by rudiedirkx, ParisLiakos: Fieldblock's
 entity view alter should be the very last

---
 fieldblock.module | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/fieldblock.module b/fieldblock.module
index fa31053..22dacd0 100644
--- a/fieldblock.module
+++ b/fieldblock.module
@@ -7,6 +7,26 @@
 
 define('FIELDBLOCK_STORAGE_STATIC', 'fieldblock_storage');
 
+/**
+ * Implements hook_module_implements_alter().
+ */
+function fieldblock_module_implements_alter(&$implementations, $hook) {
+  // Move these hooks to the end of the execution list. Even though Fieldblock only implements
+  // hook_entity_view_alter, module_implements() indexes them by first-called, which is the most
+  // specific, so we need those too.
+  $view_alter_hooks = array(
+    'entity_view_alter',
+    'node_view_alter',
+    'taxonomy_term_alter',
+    'user_view_alter',
+  );
+  if (in_array($hook, $view_alter_hooks) && isset($implementations['fieldblock'])) {
+    $group = $implementations['fieldblock'];
+    unset($implementations['fieldblock']);
+    $implementations['fieldblock'] = $group;
+  }
+}
+
 /**
  * Implements hook_form_alter().
  * Adds a column to the "display fields" table-form, with a checkbox for each
-- 
GitLab