You are here

function user_revision_entity_presave in User Revision 8

Implements hook_entity_presave().

File

./user_revision.install, line 48
Install, update and uninstall functions for the user revision module.

Code

function user_revision_entity_presave(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() == 'user') {
    $all_users =& drupal_static('user_revision_all_users', array());
    if (isset($all_users[$entity
      ->id()]) && isset($all_users[$entity
      ->id()]['pass'])) {
      $entity
        ->set('pass', current($all_users[$entity
        ->id()]['pass'])['value']);
    }
    if (isset($all_users[$entity
      ->id()]) && isset($all_users[$entity
      ->id()]['changed'])) {
      $entity
        ->set('changed', current($all_users[$entity
        ->id()]['changed'])['value']);
    }
  }
}