You are here

public function UserRestrictionsManager::matchesRestrictions in User restrictions 8

Check if a the given data matches any restrictions.

Parameters

array $data: Data to check.

Return value

bool TRUE if the data matches a restriction, FALSE otherwise.

Overrides UserRestrictionsManagerInterface::matchesRestrictions

File

src/UserRestrictionsManager.php, line 64

Class

UserRestrictionsManager
Defines the user restriction manager.

Namespace

Drupal\user_restrictions

Code

public function matchesRestrictions(array $data) {

  /** @var \Drupal\user_restrictions\Plugin\UserRestrictionTypeInterface $type */
  foreach ($this->typeManager
    ->getTypes() as $key => $type) {
    if ($type
      ->matches($data)) {
      $this
        ->setError($key, $type
        ->getErrorMessage());

      // Break after first match.
      return TRUE;
    }
  }

  // No restrictions match.
  return FALSE;
}