You are here

public function SalesforceMapping::postSave in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_mapping/src/Entity/SalesforceMapping.php \Drupal\salesforce_mapping\Entity\SalesforceMapping::postSave()
  2. 8.3 modules/salesforce_mapping/src/Entity/SalesforceMapping.php \Drupal\salesforce_mapping\Entity\SalesforceMapping::postSave()

Acts on a saved entity before the insert or update hook is invoked.

Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.

Overrides EntityBase::postSave

File

modules/salesforce_mapping/src/Entity/SalesforceMapping.php, line 321

Class

SalesforceMapping
Defines a Salesforce Mapping configuration entity class.

Namespace

Drupal\salesforce_mapping\Entity

Code

public function postSave(EntityStorageInterface $storage, $update = TRUE) {

  // Update shared pull values across other mappings to same object type.
  $pull_mappings = $storage
    ->loadByProperties([
    'salesforce_object_type' => $this->salesforce_object_type,
  ]);
  unset($pull_mappings[$this
    ->id()]);
  foreach ($pull_mappings as $mapping) {
    if ($this->pull_frequency != $mapping->pull_frequency) {
      $mapping->pull_frequency = $this->pull_frequency;
      $mapping
        ->save();
    }
  }
}