public function SalesforceMapping::getKeyValue in Salesforce Suite 8.3
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping/src/Entity/SalesforceMapping.php \Drupal\salesforce_mapping\Entity\SalesforceMapping::getKeyValue()
- 5.0.x modules/salesforce_mapping/src/Entity/SalesforceMapping.php \Drupal\salesforce_mapping\Entity\SalesforceMapping::getKeyValue()
Given a Drupal entity, get the value to be upserted.
Return value
mixed The upsert field value.
Overrides SalesforceMappingInterface::getKeyValue
File
- modules/
salesforce_mapping/ src/ Entity/ SalesforceMapping.php, line 377
Class
- SalesforceMapping
- Defines a Salesforce Mapping configuration entity class.
Namespace
Drupal\salesforce_mapping\EntityCode
public function getKeyValue(EntityInterface $entity) {
if (!$this
->hasKey()) {
throw new \Exception('No key defined for this mapping.');
}
// @TODO #fieldMappingField
foreach ($this
->getFieldMappings() as $field_plugin) {
if ($field_plugin
->get('salesforce_field') == $this
->getKeyField()) {
return $field_plugin
->value($entity, $this);
}
}
throw new \Exception(t('Key %key not found for this mapping.', [
'%key' => $this
->getKeyField(),
]));
}