You are here

function hooks_example_hooks_example_count_incremented in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 hooks_example/hooks_example.module \hooks_example_hooks_example_count_incremented()

Implements hook_hooks_example_count_incremented().

Hooks can be implemented by both the module that invokes them like we are doing here, as well as by any other enabled module.

Related topics

File

modules/hooks_example/hooks_example.module, line 218
Examples demonstrating how to implement and invoke hooks.

Code

function hooks_example_hooks_example_count_incremented($current_count, NodeInterface $node) {
  if ($current_count === 1) {
    \Drupal::messenger()
      ->addMessage(t('This is the first time you have viewed the node %title.', [
      '%title' => $node
        ->label(),
    ]));
  }
}