class PropertiesExtended in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/PropertiesExtended.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\PropertiesExtended
- 8.3 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/PropertiesExtended.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\PropertiesExtended
Adapter for entity properties and fields.
Plugin annotation
@Plugin(
id = "properties_extended",
label = @Translation("Properties, Extended")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase implements SalesforceMappingFieldPluginInterface
- class \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\PropertiesBase
- class \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\PropertiesExtended
- class \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\PropertiesBase
- class \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase implements SalesforceMappingFieldPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of PropertiesExtended
File
- modules/
salesforce_mapping/ src/ Plugin/ SalesforceMappingField/ PropertiesExtended.php, line 21
Namespace
Drupal\salesforce_mapping\Plugin\SalesforceMappingFieldView source
class PropertiesExtended extends PropertiesBase {
/**
* {@inheritdoc}
*/
public function getPluginDefinition() {
$definition = parent::getPluginDefinition();
$field_name = $this
->config('drupal_field_value');
if (strpos($field_name, '.')) {
list($field_name, $dummy) = explode('.', $field_name, 2);
}
// Add reference field.
if ($field = FieldConfig::loadByName($this->mapping
->getDrupalEntityType(), $this->mapping
->getDrupalBundle(), $field_name)) {
$definition['config_dependencies']['config'][] = $field
->getConfigDependencyName();
// Add dependencies of referenced field.
foreach ($field
->getDependencies() as $type => $dependency) {
foreach ($dependency as $item) {
$definition['config_dependencies'][$type][] = $item;
}
}
}
return $definition;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$pluginForm = parent::buildConfigurationForm($form, $form_state);
$mapping = $form['#entity'];
// Display the plugin config form here:
$context_name = 'drupal_field_value';
// If the form has been submitted already, take the mode from the submitted
// values, otherwise default to existing configuration. And if that does not
// exist default to the "input" mode.
$mode = $form_state
->get('context_' . $context_name);
if (!$mode) {
$mode = 'selector';
$form_state
->set('context_' . $context_name, $mode);
}
$title = $mode == 'selector' ? $this
->t('Data selector') : $this
->t('Value');
$pluginForm[$context_name]['setting'] = [
'#type' => 'textfield',
'#title' => $title,
'#attributes' => [
'class' => [
'drupal-field-value',
],
],
'#default_value' => $this
->config('drupal_field_value'),
];
$element =& $pluginForm[$context_name]['setting'];
if ($mode == 'selector') {
$element['#description'] = $this
->t("The data selector helps you drill down into the data available.");
$element['#autocomplete_route_name'] = 'salesforce_mapping.autocomplete_controller_autocomplete';
$element['#autocomplete_route_parameters'] = [
'entity_type_id' => $mapping
->get('drupal_entity_type'),
'bundle' => $mapping
->get('drupal_bundle'),
];
}
$value = $mode == 'selector' ? $this
->t('Switch to the direct input mode') : $this
->t('Switch to data selection');
$pluginForm[$context_name]['switch_button'] = [
'#type' => 'submit',
'#name' => 'context_' . $context_name,
'#attributes' => [
'class' => [
'drupal-field-switch-button',
],
],
'#parameter' => $context_name,
'#value' => $value,
'#submit' => [
static::class . '::switchContextMode',
],
// Do not validate!
'#limit_validation_errors' => [],
];
return $pluginForm;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
// Resetting the `drupal_field_value` to just the `setting` portion,
// which should be a string.
$config_value = $form_state
->getValue('config');
$config_value['drupal_field_value'] = $config_value['drupal_field_value']['setting'];
$form_state
->setValue('config', $config_value);
}
/**
* {@inheritdoc}
*/
protected function getDrupalFieldType(DataDefinitionInterface $data_definition) {
$field_main_property = $data_definition;
if ($data_definition instanceof ComplexDataDefinitionInterface) {
$field_main_property = $data_definition
->getPropertyDefinition($data_definition
->getMainPropertyName());
}
return $field_main_property ? $field_main_property
->getDataType() : NULL;
}
/**
* Submit callback: switch a context to data selector or direct input mode.
*/
public static function switchContextMode(array &$form, FormStateInterface $form_state) {
$element_name = $form_state
->getTriggeringElement()['#name'];
$mode = $form_state
->get($element_name);
$switched_mode = $mode == 'selector' ? 'input' : 'selector';
$form_state
->set($element_name, $switched_mode);
$form_state
->setRebuild();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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 plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PropertiesBase:: |
protected | property | Data fetcher service. | |
PropertiesBase:: |
public | function |
On dependency removal, determine if this plugin needs to be removed. Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesBase:: |
public static | function |
Creates an instance of the plugin. Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesBase:: |
public | function | Data fetcher getter. | |
PropertiesBase:: |
protected | function | Another helper Method to check for and retrieve field data. | |
PropertiesBase:: |
protected | function |
Helper method to get the Data Definition for the current field. Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesBase:: |
protected | function | Helper Method to check for and retrieve field data. | |
PropertiesBase:: |
public | function |
Pull callback for field plugins. Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesBase:: |
public | function |
Implements PluginFormInterface::validateConfigurationForm(). Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesBase:: |
public | function |
Given a Drupal entity, return the outbound value. Overrides SalesforceMappingFieldPluginInterface:: |
|
PropertiesExtended:: |
public | function |
Form constructor. Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesExtended:: |
protected | function |
Helper method to get the Field Type of the given Field Data Definition. Overrides PropertiesBase:: |
|
PropertiesExtended:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginBase:: |
|
PropertiesExtended:: |
public | function |
Implements PluginFormInterface::submitConfigurationForm(). Overrides SalesforceMappingFieldPluginBase:: |
|
PropertiesExtended:: |
public static | function | Submit callback: switch a context to data selector or direct input mode. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Entity field manager service. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Entity type bundle info service. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Entity type manager service. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Event dispatcher service. | |
SalesforceMappingFieldPluginBase:: |
protected | property | The machine name of the mapping. | |
SalesforceMappingFieldPluginBase:: |
protected | property | The label of the mapping. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Storage handler for Mapped Objects. | |
SalesforceMappingFieldPluginBase:: |
protected | property | The mapping to which this instance is attached. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Storage handler for SF mappings. | |
SalesforceMappingFieldPluginBase:: |
protected | property | Salesforce client service. | |
SalesforceMappingFieldPluginBase:: |
protected | function | Helper for buildConfigurationForm() to build a broken field plugin. | |
SalesforceMappingFieldPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
In order to set a config value to null, use setConfiguration() Overrides SalesforceMappingFieldPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Used for returning values by key. Overrides SalesforceMappingFieldPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
SalesforceMappingFieldPluginBase:: |
protected | function | Helper to retreive a list of fields for a given object type. | |
SalesforceMappingFieldPluginBase:: |
protected | function | Return TRUE if the given field uses an entity reference handler. | |
SalesforceMappingFieldPluginBase:: |
public static | function |
Determine whether this plugin is allowed for a given mapping. Overrides SalesforceMappingFieldPluginInterface:: |
4 |
SalesforceMappingFieldPluginBase:: |
public | function |
Returns label of the mapping field plugin. Overrides SalesforceMappingFieldPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Whether this plugin supports "pull" operations. Overrides SalesforceMappingFieldPluginInterface:: |
6 |
SalesforceMappingFieldPluginBase:: |
public | function |
Whether this plugin supports "push" operations. Overrides SalesforceMappingFieldPluginInterface:: |
1 |
SalesforceMappingFieldPluginBase:: |
public | function |
Munge the value that's being prepared to push to Salesforce. Overrides SalesforceMappingFieldPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
protected | function | Wraper for plugin.manager.entity_reference_selection service. | |
SalesforceMappingFieldPluginBase:: |
public | function |
Used for returning values by key. Overrides SalesforceMappingFieldPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
SalesforceMappingFieldPluginBase constructor. Overrides PluginBase:: |
1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |