You are here

function hook_nodeviewcount_insert in Node view count 8

Acts when new nodeviewcount record tries to be inserted into database.

This hook can return FALSE to prevent insertion of nodeviewcount record.

Parameters

\Drupal\node\NodeInterface $node: The node object to be recorded in nodeviewcount statistics.

string $view_mode: View mode of the node.

Return value

bool FALSE to prevent insertion of new nodeviewcount record.

1 function implements hook_nodeviewcount_insert()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

nodeviewcount_hooks_test_nodeviewcount_insert in tests/modules/nodeviewcount_hooks_test/nodeviewcount_hooks_test.module
Implements hook_nodeviewcount_insert().
1 invocation of hook_nodeviewcount_insert()
NodeViewCountController::updateCounter in src/Controller/NodeViewCountController.php
Ajax request handler for updating node's view count statistics.

File

./nodeviewcount.api.php, line 28
Documentation for nodeviewcount module API.

Code

function hook_nodeviewcount_insert(NodeInterface $node, $view_mode) {

  // Record statistics only for nodes in default language.
  if (!$node
    ->language()
    ->isDefault()) {
    return FALSE;
  }
  return TRUE;
}