You are here

public function SalesforceMapping::onDependencyRemoval 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::onDependencyRemoval()

Informs the entity that entities it depends on will be deleted.

This method allows configuration entities to remove dependencies instead of being deleted themselves. Configuration entities can use this method to avoid being unnecessarily deleted during an extension uninstallation. For example, entity displays remove references to widgets and formatters if the plugin that supplies them depends on a module that is being uninstalled.

If this method returns TRUE then the entity needs to be re-saved by the caller for the changes to take effect. Implementations should not save the entity.

Parameters

array $dependencies: An array of dependencies that will be deleted keyed by dependency type. Dependency types are, for example, entity, module and theme.

Return value

bool TRUE if the entity has been changed as a result, FALSE if not.

Overrides ConfigEntityBase::onDependencyRemoval

See also

\Drupal\Core\Config\Entity\ConfigDependencyManager

\Drupal\Core\Config\ConfigEntityBase::preDelete()

\Drupal\Core\Config\ConfigManager::uninstall()

\Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval()

File

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

Class

SalesforceMapping
Defines a Salesforce Mapping configuration entity class.

Namespace

Drupal\salesforce_mapping\Entity

Code

public function onDependencyRemoval(array $dependencies) {
  parent::onDependencyRemoval($dependencies);

  // If the mapped entity type is being removed, we'll delete this mapping.
  $entity_type = $this
    ->entityTypeManager()
    ->getDefinition($this
    ->getDrupalEntityType());
  $dependency = $entity_type
    ->getBundleConfigDependency($this
    ->getDrupalBundle());
  if (!empty($dependencies[$dependency['type']][$dependency['name']])) {
    return FALSE;
  }

  // Otherwise, ask each field mapping plugin if wants to remove itself.
  return $this
    ->removePluginDependencies($dependencies);
}