You are here

public function AccessStorage::checkIfUsersExists in Permissions by Term 8

Same name and namespace in other branches
  1. 8.2 src/Service/AccessStorage.php \Drupal\permissions_by_term\Service\AccessStorage::checkIfUsersExists()

Parameters

FormState $form_state:

File

src/Service/AccessStorage.php, line 96

Class

AccessStorage
Class AccessStorage.

Namespace

Drupal\permissions_by_term\Service

Code

public function checkIfUsersExists(FormState $form_state) {
  $sAllowedUsers = $form_state
    ->getValue('access')['user'];
  $aAllowedUsers = Tags::explode($sAllowedUsers);
  foreach ($aAllowedUsers as $sUserId) {
    $aUserId = \Drupal::entityQuery('user')
      ->condition('uid', $sUserId)
      ->execute();
    if (empty($aUserId)) {
      $form_state
        ->setErrorByName('access][user', t('The user with ID %user_id does not exist.', [
        '%user_id' => $sUserId,
      ]));
    }
  }
}