changed_fields_basic_usage.module in Changed Fields API 8.2
Same filename and directory in other branches
- 8.3 examples/changed_fields_basic_usage/changed_fields_basic_usage.module
- 8 examples/changed_fields_basic_usage/changed_fields_basic_usage.module
- 7.3 examples/changed_fields_basic_usage/changed_fields_basic_usage.module
- 7 examples/changed_fields_basic_usage/changed_fields_basic_usage.module
- 7.2 examples/changed_fields_basic_usage/changed_fields_basic_usage.module
Contains changed_fields_basic_usage.module.
File
examples/changed_fields_basic_usage/changed_fields_basic_usage.moduleView source
<?php
/**
* @file
* Contains changed_fields_basic_usage.module.
*/
use Drupal\changed_fields\NodeSubject;
use Drupal\changed_fields_basic_usage\BasicUsageObserver;
use Drupal\node\NodeInterface;
/**
* Implements hook_node_presave().
*/
function changed_fields_basic_usage_node_presave(NodeInterface $node) {
// Create NodeSubject object that will check node fields by DefaultFieldComparator.
$nodeSubject = new NodeSubject($node, 'default_field_comparator');
// Add your observer object to NodeSubject.
$nodeSubject
->attach(new BasicUsageObserver());
// Check if node fields have been changed.
$nodeSubject
->notify();
}
Functions
Name | Description |
---|---|
changed_fields_basic_usage_node_presave | Implements hook_node_presave(). |