class LinkAddressfield in Conditional Fields 4.x
Same name and namespace in other branches
- 8 src/Plugin/conditional_fields/handler/extra_contrib/LinkAddressfield.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\extra_contrib\LinkAddressfield
Provides states handler for links provided by the Addressfield module.
Plugin annotation
@ConditionalFieldsHandler(
id = "states_handler_address_default",
)
Hierarchy
- class \Drupal\conditional_fields\ConditionalFieldsHandlerBase implements ConditionalFieldsHandlersPluginInterface
- class \Drupal\conditional_fields\Plugin\conditional_fields\handler\extra_contrib\LinkAddressfield
Expanded class hierarchy of LinkAddressfield
File
- src/
Plugin/ conditional_fields/ handler/ extra_contrib/ LinkAddressfield.php, line 15
Namespace
Drupal\conditional_fields\Plugin\conditional_fields\handler\extra_contribView source
class LinkAddressfield extends ConditionalFieldsHandlerBase {
/**
* {@inheritdoc}
*/
public function statesHandler($field, $field_info, $options) {
$state = [];
if ($options['values_set'] != ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET) {
return $state;
}
$regex = $options['values_set'] == ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX;
$keys = [];
if ($field['#handlers']['address']) {
$keys += [
'country',
'thoroughfare',
'premise',
'postal_code',
'locality',
'administrative_area',
];
}
if ($field['#handlers']['organisation']) {
$keys += [
'organisation_name',
];
}
if ($field['#handlers']['name-oneline']) {
$keys += [
'name_line',
];
}
elseif ($field['#handlers']['name-full']) {
$keys += [
'first_name',
'last_name',
];
}
$addressfield_selectors = [];
foreach ($keys as $key) {
$addressfield_selectors[str_replace('%key', $key, $options['selector'])] = [
'value' => $regex ? $options['value'] : $options['value'][0][$key],
];
}
$state = [
$options['state'] => $addressfield_selectors,
];
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 |
LinkAddressfield:: |
public | function |
Executes states handler according to conditional fields settings. Overrides ConditionalFieldsHandlersPluginInterface:: |