You are here

function opigno_moxtra_user_presave in Opigno Moxtra 3.x

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

Implements hook_ENTITY_TYPE_presave().

Checks user quota.

File

./opigno_moxtra.module, line 426
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.'));
    }
  }
}