abstract class FieldMappingBase in Webform Content Creator 3.x
Base for a field mapping plugin.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\webform_content_creator\Plugin\FieldMappingBase implements FieldMappingInterface
Expanded class hierarchy of FieldMappingBase
10 files declare their use of FieldMappingBase
- AddressFieldMapping.php in src/
Plugin/ WebformContentCreator/ FieldMapping/ AddressFieldMapping.php - BooleanFieldMapping.php in src/
Plugin/ WebformContentCreator/ FieldMapping/ BooleanFieldMapping.php - DateTimeFieldMapping.php in src/
Plugin/ WebformContentCreator/ FieldMapping/ DateTimeFieldMapping.php - DefaultFieldMapping.php in src/
Plugin/ WebformContentCreator/ FieldMapping/ DefaultFieldMapping.php - EmailFieldMapping.php in src/
Plugin/ WebformContentCreator/ FieldMapping/ EmailFieldMapping.php
File
- src/
Plugin/ FieldMappingBase.php, line 13
Namespace
Drupal\webform_content_creator\PluginView source
abstract class FieldMappingBase extends PluginBase implements FieldMappingInterface {
/**
* Return the plugin.
*/
public function getPlugin() {
return $this;
}
/**
* Get the plugin ID.
*/
public function getId() {
return $this->pluginDefinition['id'];
}
/**
* Get the plugin label.
*/
public function getLabel() {
return $this->pluginDefinition['label'];
}
/**
* Get the plugin weight.
*/
public function getWeight() {
return $this->pluginDefinition['weight'];
}
/**
* Get the field types this plugin is available for.
*/
public function getFieldTypes() {
return $this->pluginDefinition['field_types'];
}
/**
* Is this a generic (non-element specific) plugin.
*/
public function isGeneric() {
return empty($this->pluginDefinition['field_types']) ? TRUE : FALSE;
}
public function supportsCustomFields() {
return TRUE;
}
public function getEntityComponentFields(FieldDefinitionInterface $field_definition) {
return [];
}
public function getSupportedWebformFields($webform_id) {
return WebformContentCreatorUtilities::getWebformElements($webform_id);
}
/**
* Use a single mapping to set an entity field value.
*/
public function mapEntityField(ContentEntityInterface &$content, array $webform_element, array $data = [], FieldDefinitionInterface $field_definition) {
$field_id = $field_definition
->getName();
$field_value = $data[$field_id];
$content
->set($field_id, $field_value);
}
protected function filterWebformFields($webform_id, array $supported_types, array $available_fields = NULL) {
if (!isset($available_fields)) {
$available_fields = WebformContentCreatorUtilities::getWebformElements($webform_id);
}
$webform_field_types = WebformContentCreatorUtilities::getWebformElementsTypes($webform_id);
$allowed_fields = [];
foreach ($available_fields as $key => $available_field) {
$key_parts = explode(',', $key);
if (sizeOf($key_parts) > 1) {
$element_type = $webform_field_types[$key_parts[1]];
//Webform field vs user added fields
if ($key_parts[0] == "1") {
$element_type = $element_type['type'];
}
if (in_array($element_type, $supported_types)) {
$allowed_fields[$key] = $available_field;
}
}
else {
//We're dealing with an option group, so recursive call to process the sub fields
$retval = $this
->filterWebformFields($webform_id, $supported_types, $available_field);
if (!empty($retval)) {
$allowed_fields[$key] = $retval;
}
}
}
return $allowed_fields;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldMappingBase:: |
protected | function | ||
FieldMappingBase:: |
public | function |
Returns the entity component fields. Overrides FieldMappingInterface:: |
1 |
FieldMappingBase:: |
public | function | Get the field types this plugin is available for. | |
FieldMappingBase:: |
public | function | Get the plugin ID. | |
FieldMappingBase:: |
public | function | Get the plugin label. | |
FieldMappingBase:: |
public | function | Return the plugin. | |
FieldMappingBase:: |
public | function |
Overrides FieldMappingInterface:: |
9 |
FieldMappingBase:: |
public | function | Get the plugin weight. | |
FieldMappingBase:: |
public | function | Is this a generic (non-element specific) plugin. | |
FieldMappingBase:: |
public | function |
Use a single mapping to set an entity field value. Overrides FieldMappingInterface:: |
10 |
FieldMappingBase:: |
public | function |
Returns whether the mapper supports custom field text Overrides FieldMappingInterface:: |
2 |
FieldMappingInterface:: |
constant | |||
FieldMappingInterface:: |
constant | |||
FieldMappingInterface:: |
constant | |||
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 98 |