You are here

public function AccessStorage::getSubmittedUserIds 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::getSubmittedUserIds()

Gets the user ids which have been submitted by form.

Users which will gain granted access to taxonomy terms.

Return value

array The user ids which have been submitted.

1 call to AccessStorage::getSubmittedUserIds()
AccessStorage::saveTermPermissions in src/Service/AccessStorage.php
*

File

src/Service/AccessStorage.php, line 364

Class

AccessStorage
Class AccessStorage.

Namespace

Drupal\permissions_by_term\Service

Code

public function getSubmittedUserIds($formState) {

  /* There's a $this->oFormState->getValues() method, but
   * it is loosing multiple form values. Don't know why.
   * So there're some custom lines on the $_REQUEST array. */
  $sRawUsers = $_REQUEST['access']['user'];
  if (empty($sRawUsers)) {
    return [];
  }
  $aRawUsers = Tags::explode($sRawUsers);
  $aUserIds = [];
  if (!empty($aRawUsers)) {
    foreach ($aRawUsers as $sRawUser) {
      if (preg_match("/.+\\s\\(([^\\)]+)\\)/", $sRawUser, $matches)) {
        $aUserIds[] = $matches[1];
      }
    }
  }
  return $aUserIds;
}