class Properties in Salesforce Suite 8.3
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Properties.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\Properties
- 5.0.x modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Properties.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\Properties
Adapter for entity properties and fields.
Plugin annotation
@Plugin(
id = "properties",
label = @Translation("Properties")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase implements ConfigurablePluginInterface, ContainerFactoryPluginInterface, PluginFormInterface, SalesforceMappingFieldPluginInterface
- class \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\Properties
- class \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase implements ConfigurablePluginInterface, ContainerFactoryPluginInterface, PluginFormInterface, SalesforceMappingFieldPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Properties
1 file declares its use of Properties
- SalesforceMappingTest.php in modules/
salesforce_mapping/ tests/ src/ Unit/ SalesforceMappingTest.php
1 string reference to 'Properties'
- SalesforceMappingList::getDefaultOperations in modules/
salesforce_mapping/ src/ SalesforceMappingList.php - Gets this list's default operations.
File
- modules/
salesforce_mapping/ src/ Plugin/ SalesforceMappingField/ Properties.php, line 18
Namespace
Drupal\salesforce_mapping\Plugin\SalesforceMappingFieldView source
class Properties extends SalesforceMappingFieldPluginBase {
/**
* Implementation of PluginFormInterface::buildConfigurationForm.
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$pluginForm = parent::buildConfigurationForm($form, $form_state);
// @TODO inspecting the form and form_state feels wrong, but haven't found a good way to get the entity from config before the config is saved.
$options = $this
->getConfigurationOptions($form['#entity']);
// Display the plugin config form here:
if (empty($options)) {
$pluginForm['drupal_field_value'] = [
'#markup' => t('No available properties.'),
];
}
else {
$pluginForm['drupal_field_value'] += [
'#type' => 'select',
'#options' => $options,
'#empty_option' => $this
->t('- Select -'),
'#default_value' => $this
->config('drupal_field_value'),
'#description' => $this
->t('Select a Drupal field or property to map to a Salesforce field.<br />Entity Reference fields should be handled using Related Entity Ids or Token field types.'),
];
}
return $pluginForm;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
$vals = $form_state
->getValues();
$config = $vals['config'];
if (empty($config['salesforce_field'])) {
$form_state
->setError($form['config']['salesforce_field'], t('Salesforce field is required.'));
}
if (empty($config['drupal_field_value'])) {
$form_state
->setError($form['config']['drupal_field_value'], t('Drupal field is required.'));
}
}
/**
* {@inheritdoc}
*/
public function value(EntityInterface $entity, SalesforceMappingInterface $mapping) {
// No error checking here. If a property is not defined, it's a
// configuration bug that needs to be solved elsewhere.
// Multipicklist is the only target type that handles multi-valued fields.
$describe = $this->salesforceClient
->objectDescribe($mapping
->getSalesforceObjectType());
$field_definition = $describe
->getField($this
->config('salesforce_field'));
if ($field_definition['type'] == 'multipicklist') {
$values = [];
foreach ($entity
->get($this
->config('drupal_field_value')) as $value) {
$values[] = $value->value;
}
return implode(';', $values);
}
else {
return $entity
->get($this
->config('drupal_field_value'))->value;
}
}
/**
* Form options helper.
*/
private function getConfigurationOptions(SalesforceMappingInterface $mapping) {
$instances = $this->entityFieldManager
->getFieldDefinitions($mapping
->get('drupal_entity_type'), $mapping
->get('drupal_bundle'));
$options = [];
foreach ($instances as $key => $instance) {
// Entity reference fields are handled elsewhere.
if ($this
->instanceOfEntityReference($instance)) {
continue;
}
$options[$key] = $instance
->getLabel();
}
asort($options);
return $options;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
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 definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
Properties:: |
public | function |
Implementation of PluginFormInterface::buildConfigurationForm. Overrides SalesforceMappingFieldPluginBase:: |
|
Properties:: |
private | function | Form options helper. | |
Properties:: |
public | function |
Implements PluginFormInterface::validateConfigurationForm(). Overrides SalesforceMappingFieldPluginBase:: |
|
Properties:: |
public | function |
Given a Drupal entity, return the outbound value. Overrides SalesforceMappingFieldPluginInterface:: |
|
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 | 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 static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
2 |
SalesforceMappingFieldPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurablePluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Used for returning values by key. Overrides SalesforceMappingFieldPluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurablePluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Return an array of dependencies. Overrides SalesforceMappingFieldPluginInterface:: |
1 |
SalesforceMappingFieldPluginBase:: |
protected | function | Helper method to get the Field Type of the given Field Data Definition. | 1 |
SalesforceMappingFieldPluginBase:: |
protected | function | Helper method to get the Data Definition for the current field. | 1 |
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:: |
5 |
SalesforceMappingFieldPluginBase:: |
public | function |
Pull callback for field plugins. Overrides SalesforceMappingFieldPluginInterface:: |
2 |
SalesforceMappingFieldPluginBase:: |
public | function |
Whether this plugin supports "push" operations. Overrides SalesforceMappingFieldPluginInterface:: |
|
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 ConfigurablePluginInterface:: |
|
SalesforceMappingFieldPluginBase:: |
public | function |
Implements PluginFormInterface::submitConfigurationForm(). Overrides PluginFormInterface:: |
1 |
SalesforceMappingFieldPluginBase:: |
public | function |
SalesforceMappingFieldPluginBase constructor. Overrides PluginBase:: |
2 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
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. |