You are here

public function ConfigPagesValueAccess::evaluate in Config Pages 8.2

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

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

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

Class

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

Namespace

Drupal\config_pages\Plugin\Condition

Code

public function evaluate() {
  $config = $this
    ->getConfiguration();
  if (isset($config['config_page_field'], $config['operator'], $config['condition_value'])) {
    $config_page_field = $config['config_page_field'];
    $operator = $config['operator'];
    $condition_value = $config['condition_value'];
    list($cp_type, $field, $data_type) = explode('|', $config_page_field);

    // Get field value.
    $field_value = $this->configPagesLoader
      ->getValue($cp_type, $field, 0, 'value');
    return $this
      ->compareValues($condition_value, $field_value, $operator);
  }
  return TRUE;
}