+ /**
+ * {@inheritdoc}
+ */
+ public function invokeDeprecated($description, $module, $hook, array $args = []) {
+ $result = $this->invoke($module, $hook, $args);
+ $this->triggerDeprecationError($description, $hook);
+ return $result;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function invokeAllDeprecated($description, $hook, array $args = []) {
+ $result = $this->invokeAll($hook, $args);
+ $this->triggerDeprecationError($description, $hook);
+ return $result;
+ }
+
+
+ /**
+ * Triggers an E_USER_DEPRECATED error if any module implements the hook.
+ *
+ * @param string $description
+ * Helpful text describing what to do instead of implementing this hook.
+ * @param string $hook
+ * The name of the hook.
+ */
+ private function triggerDeprecationError($description, $hook) {
+ $modules = array_keys($this->getImplementationInfo($hook));
+ if (!empty($modules)) {
+ $message = 'The deprecated hook hook_' . $hook . '() is implemented in these functions: ';
+ $implementations = array_map(function ($module) use ($hook) {
+ return $module . '_' . $hook . '()';
+ }, $modules);
+ @trigger_error($message . implode(', ', $implementations) . '. ' . $description, E_USER_DEPRECATED);
+ }
+ }
+