You are here

event_log_track_node.module in Events Log Track 8

Same filename and directory in other branches
  1. 8.2 event_log_track_node/event_log_track_node.module

Logs node CUD commands in the event_log_track module.

File

event_log_track_node/event_log_track_node.module
View source
<?php

/**
 * @file
 * Logs node CUD commands in the event_log_track module.
 */

/**
 * Implements hook_event_log_track_handlers().
 */
function event_log_track_node_event_log_track_handlers() {

  // Node event log handler.
  $handlers = array();
  $handlers['node'] = array(
    'title' => t('Node'),
  );
  return $handlers;
}

/**
 * Implements hook_node_insert().
 */
function event_log_track_node_insert($node) {
  $log = array(
    'type' => 'node',
    'operation' => 'insert',
    'description' => t('%type: %title', array(
      '%type' => $node
        ->getType(),
      '%title' => $node
        ->getTitle(),
    )),
    'ref_numeric' => $node
      ->id(),
    'ref_char' => $node
      ->getTitle(),
  );
  event_log_track_insert($log);
}

/**
 * Implements hook_node_update().
 */
function event_log_track_node_update($node) {
  $log = array(
    'type' => 'node',
    'operation' => 'update',
    'description' => t('%type: %title', array(
      '%type' => $node
        ->getType(),
      '%title' => $node
        ->getTitle(),
    )),
    'ref_numeric' => $node
      ->id(),
    'ref_char' => $node
      ->getTitle(),
  );
  event_log_track_insert($log);
}

/**
 * Implements hook_node_delete().
 */
function event_log_track_node_delete($node) {
  $log = array(
    'type' => 'node',
    'operation' => 'delete',
    'description' => t('%type: %title', array(
      '%type' => $node
        ->getType(),
      '%title' => $node
        ->getTitle(),
    )),
    'ref_numeric' => $node
      ->id(),
    'ref_char' => $node
      ->getTitle(),
  );
  event_log_track_insert($log);
}

Functions

Namesort descending Description
event_log_track_node_delete Implements hook_node_delete().
event_log_track_node_event_log_track_handlers Implements hook_event_log_track_handlers().
event_log_track_node_insert Implements hook_node_insert().
event_log_track_node_update Implements hook_node_update().