You are here

function opigno_moxtra_user_presave in Opigno Moxtra 8

Same name and namespace in other branches
  1. 3.x opigno_moxtra.module \opigno_moxtra_user_presave()

Implements hook_ENTITY_TYPE_presave().

Checks user quota.

File

./opigno_moxtra.module, line 424
Contains opigno_moxtra.module.

Code

function opigno_moxtra_user_presave(EntityInterface $entity) {
  if (!_opigno_moxtra_is_active()) {
    return;
  }

  /** @var \Drupal\user\Entity\User $entity */
  if (_opigno_moxtra_is_user_enabled($entity)) {
    if (!_opigno_moxtra_check_user_quota()) {
      _opigno_moxtra_disable_user($entity, FALSE);
      \Drupal::messenger()
        ->addWarning(t('You have reached the Moxtra user limit.'));
    }
  }
}