You are here

abstract class ConditionalFieldsHandlerBase in Conditional Fields 4.x

Same name and namespace in other branches
  1. 8 src/ConditionalFieldsHandlerBase.php \Drupal\conditional_fields\ConditionalFieldsHandlerBase

Defines a base handler implementation that most handlers plugins will extend.

Hierarchy

Expanded class hierarchy of ConditionalFieldsHandlerBase

15 files declare their use of ConditionalFieldsHandlerBase
Checkbox.php in src/Plugin/conditional_fields/handler/Checkbox.php
DateDefault.php in src/Plugin/conditional_fields/handler/DateDefault.php
DateList.php in src/Plugin/conditional_fields/handler/DateList.php
DefaultStateHandler.php in src/Plugin/conditional_fields/handler/DefaultStateHandler.php
EmailDefault.php in src/Plugin/conditional_fields/handler/EmailDefault.php

... See full list

File

src/ConditionalFieldsHandlerBase.php, line 8

Namespace

Drupal\conditional_fields
View source
abstract class ConditionalFieldsHandlerBase implements ConditionalFieldsHandlersPluginInterface {

  /**
   * {@inheritdoc}
   */
  public function getWidgetValue(array $value_form) {
    if (empty($value_form)) {
      return NULL;
    }
    else {
      return $value_form[0]['value'];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getConditionValues(array $options) {
    if (isset($options['values'])) {
      $value_data = $options['values'];
    }
    else {
      $value_data = $options;
    }
    if (is_array($value_data)) {
      $values = $value_data;
    }
    elseif (is_string($value_data)) {
      $values = preg_split("/[\r\n]+/g", $value_data);
    }
    else {
      $values = [];
    }
    return $values;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConditionalFieldsHandlerBase::getConditionValues public function Get values form the condition options. Overrides ConditionalFieldsHandlersPluginInterface::getConditionValues
ConditionalFieldsHandlerBase::getWidgetValue public function Get values from widget settings for plugin. Overrides ConditionalFieldsHandlersPluginInterface::getWidgetValue 5
ConditionalFieldsHandlersPluginInterface::statesHandler public function Executes states handler according to conditional fields settings. 15