You are here

function salesforce_mapping_entity_type_alter in Salesforce Suite 8.3

Implements hook_entity_type_alter().

File

modules/salesforce_mapping/salesforce_mapping.module, line 13
Manages Salesforce object and Drupal entity mappings.

Code

function salesforce_mapping_entity_type_alter(array &$entity_types) {

  // There's no good way to add a link template based on existing mapping
  // definitions while we're building entity type definitions. We can't load
  // existing mappings, because to do that we need to load entity types which
  // creates an infinite recursion. So, we set the link template on any
  // mappable entity, and hide it for any entity types that don't have
  // mappings.
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type
      ->hasViewBuilderClass() && $entity_type
      ->hasLinkTemplate('canonical')) {
      $entity_type
        ->setLinkTemplate('salesforce', "/{$entity_type_id}/{{$entity_type_id}}/salesforce");
    }
  }
}