class EmailDefault in Conditional Fields 4.x
Same name and namespace in other branches
- 8 src/Plugin/conditional_fields/handler/EmailDefault.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\EmailDefault
Provides states handler for emails.
Plugin annotation
@ConditionalFieldsHandler(
id = "states_handler_email_default",
)
Hierarchy
- class \Drupal\conditional_fields\ConditionalFieldsHandlerBase implements ConditionalFieldsHandlersPluginInterface
- class \Drupal\conditional_fields\Plugin\conditional_fields\handler\EmailDefault
Expanded class hierarchy of EmailDefault
File
- src/
Plugin/ conditional_fields/ handler/ EmailDefault.php, line 15
Namespace
Drupal\conditional_fields\Plugin\conditional_fields\handlerView source
class EmailDefault extends ConditionalFieldsHandlerBase {
/**
* {@inheritdoc}
*/
public function statesHandler($field, $field_info, $options) {
$state = [];
$values_array = $this
->getConditionValues($options);
// Email fields values are keyed by cardinality, so we have to flatten them.
// @todo support multiple values.
switch ($options['values_set']) {
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET:
foreach ($options['value_form'] as $value) {
// Fix 0 selector for multiple fields.
if (!empty($value['value'])) {
$state[$options['state']][$options['selector']] = [
'value' => $value['value'],
];
}
}
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_AND:
// @todo support AND condition.
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX:
$values[$options['condition']] = [
'regex' => $options['regex'],
];
$state[$options['state']][$options['selector']] = $values;
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_XOR:
$values[$options['condition']] = [
'xor' => $values_array,
];
$state[$options['state']][$options['selector']] = $values;
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_NOT:
$options['state'] = '!' . $options['state'];
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_OR:
if (!empty($values_array)) {
foreach ($values_array as $value) {
$input_states[$options['selector']][] = [
'value' => $value,
];
}
}
else {
$input_states[$options['selector']] = [
$options['condition'] => $values_array,
];
}
$state[$options['state']][] = $input_states;
break;
default:
break;
}
return $state;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConditionalFieldsHandlerBase:: |
public | function |
Get values form the condition options. Overrides ConditionalFieldsHandlersPluginInterface:: |
|
ConditionalFieldsHandlerBase:: |
public | function |
Get values from widget settings for plugin. Overrides ConditionalFieldsHandlersPluginInterface:: |
5 |
EmailDefault:: |
public | function |
Executes states handler according to conditional fields settings. Overrides ConditionalFieldsHandlersPluginInterface:: |