You are here

public function UserRestrictionTypeBase::getPatterns in User restrictions 8

Get the list of regular expression patterns of the type.

Return value

string[] Array with regular expression patterns.

Overrides UserRestrictionTypeInterface::getPatterns

File

src/Plugin/UserRestrictionType/UserRestrictionTypeBase.php, line 115

Class

UserRestrictionTypeBase

Namespace

Drupal\user_restrictions\Plugin\UserRestrictionType

Code

public function getPatterns() {
  if (!empty($this->patterns)) {
    return $this->patterns;
  }
  $rules = $this->entityStorage
    ->loadByProperties([
    'rule_type' => $this
      ->getPluginId(),
  ]);
  if (empty($rules)) {
    return [];
  }

  /** @var \Drupal\user_restrictions\Entity\UserRestrictions $rule */
  foreach ($rules as $id => $rule) {
    $this->patterns[$id] = $rule
      ->getPattern();
  }
  return $this->patterns;
}