Drupal does not force entity types to provide a last modified date, nor provides any standard naming convention for those that do.

This module steps in to provide a programmatic way to retrieve the name of the modified property. When the name is unknown, entity modified tracks the date itself.

This module will not provide anything worthwhile on its own, so only install this module if another module depends on it.

Use

To retrieve the last modified timestamp of an entity, you would make a call like the following:

  $modified = entity_modified_last($entity_type, $entity);

Entity type creators

If your module defines an entity type, you can let entity modified know about it by defining the 'modified property name' in hook_entity_info().

You can also alter already existing property names by using hook_entity_info_alter().

An example for a fictional module named building, that creates an entity type named window, that has a last changed property of changed follows:

/**
 * Implements hook_entity_info().
 */
function building_entity_info() {
  $types = array();
  $types['window'] = array(
    'label' => 'Window',
    // Properties from hook_entity_info() here.
    'modified property name' => 'changed',
  );
  return $types;
}

Dependencies

As of the 7.x-1.0-alpha3 release entity modified will require Entity API.

 

Created and maintained by the Bonnier Engineering Group. Learn more about Bonnier Corporation at bonniercorp.com.

 

Co-maintained by Fabianx.

 

Project information

Releases