You are here

protected function ArrayConditionBase::isMatchedWithArray in Access Filter 8

Checks matching using specific array.

Parameters

array $array: The array containing comparison.

Return value

bool Boolean TRUE if condition is matched or FALSE otherwise.

3 calls to ArrayConditionBase::isMatchedWithArray()
CookieCondition::isMatched in src/Plugin/AccessFilter/Condition/CookieCondition.php
Checks the current access is matched to the condition.
ServerEnvironmentCondition::isMatched in src/Plugin/AccessFilter/Condition/ServerEnvironmentCondition.php
Checks the current access is matched to the condition.
SessionCondition::isMatched in src/Plugin/AccessFilter/Condition/SessionCondition.php
Checks the current access is matched to the condition.

File

src/Plugin/AccessFilter/Condition/ArrayConditionBase.php, line 42

Class

ArrayConditionBase
Base class for condition plugins that checks arrays.

Namespace

Drupal\access_filter\Plugin\AccessFilter\Condition

Code

protected function isMatchedWithArray(array $array) {
  $array_value = '';
  if (isset($array[$this->configuration['key']])) {
    $array_value = $array[$this->configuration['key']];
  }
  $comparison = '';
  if (isset($this->configuration['value'])) {
    $comparison = $this->configuration['value'];
  }
  if (empty($this->configuration['regex'])) {
    return $array_value == $comparison;
  }
  else {
    return (bool) preg_match($array_value, $comparison);
  }
}