You are here

changed_fields_basic_usage.module in Changed Fields API 7.3

Basic field comparator usage example.

File

examples/changed_fields_basic_usage/changed_fields_basic_usage.module
View source
<?php

/**
 * @file
 * Basic field comparator usage example.
 */

/**
 * Implements hook_node_presave().
 */
function changed_fields_basic_usage_node_presave(stdClass $node) {

  // Create CFNodeSubject object that will check node fields by CFDefaultFieldComparator.
  $nodeSubject = new CFNodeSubject($node, new CFDefaultFieldComparator());

  // Add your observer object to CFNodeSubject.
  // See includes/changed_fields_basic_usage.observer.inc file.
  $nodeSubject
    ->attach(new BasicUsageObserver());

  // Check if node fields have been changed.
  $nodeSubject
    ->notify();
}

Functions