View source
<?php
namespace Drupal\crm_core_match\Plugin\crm_core_match\field;
class AddressFieldHandler extends FieldHandlerBase {
public function fieldRender($field, $field_info, &$form) {
foreach ($field_info['columns'] as $item => $info) {
$text_items = [
'name_line',
'first_name',
'last_name',
'organisation_name',
'administrative_area',
'sub_administrative_area',
'locality',
'dependent_locality',
'thoroughfare',
'premise',
'sub_premise',
];
$select_items = [
'country',
'postal_code',
];
$field_item['field_name'] = $field['field_name'];
$field_item['label'] = $field['label'] . ': ' . $info['description'];
$field_item['bundle'] = $field['bundle'];
$field_item['field_item'] = $item;
if (in_array($item, $select_items)) {
$item = new SelectFieldHandler();
$item
->fieldRender($field_item, $field_info, $form);
}
if (in_array($item, $text_items)) {
$item = new textMatchField();
$item
->fieldRender($field_item, $field_info, $form);
}
}
}
public function getOperators($property = 'value') {
return [
'equals' => t('Equals'),
];
}
}