Hardcoded.php in Salesforce Suite 8.3
File
modules/salesforce_example/src/Plugin/SalesforceMappingField/Hardcoded.php
View source
<?php
namespace Drupal\salesforce_example\Plugin\SalesforceMappingField;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase;
use Drupal\salesforce_mapping\Entity\SalesforceMappingInterface;
use Drupal\salesforce_mapping\MappingConstants;
class Hardcoded extends SalesforceMappingFieldPluginBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$pluginForm = parent::buildConfigurationForm($form, $form_state);
$pluginForm['drupal_field_value'] += [
'#type' => 'textfield',
'#default_value' => 'Hardcoded value',
'#description' => $this
->t('This is a hardcoded value.'),
'#disabled' => TRUE,
];
$pluginForm['direction']['#options'] = [
MappingConstants::SALESFORCE_MAPPING_DIRECTION_DRUPAL_SF => $pluginForm['direction']['#options'][MappingConstants::SALESFORCE_MAPPING_DIRECTION_DRUPAL_SF],
];
$pluginForm['direction']['#default_value'] = MappingConstants::SALESFORCE_MAPPING_DIRECTION_DRUPAL_SF;
return $pluginForm;
}
public function value(EntityInterface $entity, SalesforceMappingInterface $mapping) {
return 'Hardcoded value';
}
public function pull() {
return FALSE;
}
}
Classes
Name |
Description |
Hardcoded |
Adapter for entity Constant and fields. |