You are here

protected function ConfigPagesValueAccess::compareValues in Config Pages 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Condition/ConfigPagesValueAccess.php \Drupal\config_pages\Plugin\Condition\ConfigPagesValueAccess::compareValues()

Compare values based on operator.

Return value

bool TRUE if comprising match.

1 call to ConfigPagesValueAccess::compareValues()
ConfigPagesValueAccess::evaluate in src/Plugin/Condition/ConfigPagesValueAccess.php
Evaluates the condition and returns TRUE or FALSE accordingly.

File

src/Plugin/Condition/ConfigPagesValueAccess.php, line 253

Class

ConfigPagesValueAccess
Provides a 'Access by ConfigPage field value' condition.

Namespace

Drupal\config_pages\Plugin\Condition

Code

protected function compareValues($value, $field_value, $operator) {

  // Compare values according to operator.
  switch ($operator) {
    case '==':
      $result = $field_value == $value;
      break;
    case '<':
      $result = $field_value < $value;
      break;
    case '<=':
      $result = $field_value <= $value;
      break;
    case '!=':
      $result = $field_value != $value;
      break;
    case '>=':
      $result = $field_value >= $value;
      break;
    case '>':
      $result = $field_value > $value;
      break;
    case 'isset':
      $result = !empty($field_value) === !empty($value);
      break;
    default:
      $result = FALSE;
  }
  return $result;
}