You are here

class SalesforceMappableEntityTypes in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_mapping/src/SalesforceMappableEntityTypes.php \Drupal\salesforce_mapping\SalesforceMappableEntityTypes
  2. 8.3 modules/salesforce_mapping/src/SalesforceMappableEntityTypes.php \Drupal\salesforce_mapping\SalesforceMappableEntityTypes

Mappable entity types constructor.

Hierarchy

Expanded class hierarchy of SalesforceMappableEntityTypes

1 string reference to 'SalesforceMappableEntityTypes'
salesforce_mapping.services.yml in modules/salesforce_mapping/salesforce_mapping.services.yml
modules/salesforce_mapping/salesforce_mapping.services.yml
1 service uses SalesforceMappableEntityTypes
salesforce_mapping.mappable_entity_types in modules/salesforce_mapping/salesforce_mapping.services.yml
Drupal\salesforce_mapping\SalesforceMappableEntityTypes

File

modules/salesforce_mapping/src/SalesforceMappableEntityTypes.php, line 11

Namespace

Drupal\salesforce_mapping
View source
class SalesforceMappableEntityTypes implements SalesforceMappableEntityTypesInterface {

  /**
   * Constructs a new SalesforceMappableEntities object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_manager) {
    $this->entityTypeManager = $entity_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function getMappableEntityTypes() {
    $entity_info = $this->entityTypeManager
      ->getDefinitions();
    $mappable = [];

    // We're only concerned with fieldable entities. This is a relatively
    // arbitrary restriction, but otherwise there would be an unweildy number
    // of entities. Also exclude MappedObjects themselves.
    foreach ($entity_info as $entity_type_id => $entity_type) {
      if ($this
        ->isMappable($entity_type)) {
        $mappable[$entity_type_id] = $entity_type;
      }
    }
    return $mappable;
  }

  /**
   * {@inheritdoc}
   */
  public function isMappable(EntityTypeInterface $entity_type) {
    if (in_array('Drupal\\Core\\Entity\\ContentEntityTypeInterface', class_implements($entity_type)) && $entity_type
      ->id() != 'salesforce_mapped_object') {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SalesforceMappableEntityTypes::getMappableEntityTypes public function Get an array of entity types that are mappable. Overrides SalesforceMappableEntityTypesInterface::getMappableEntityTypes
SalesforceMappableEntityTypes::isMappable public function Given an entity type, return true or false to indicate if it's mappable. Overrides SalesforceMappableEntityTypesInterface::isMappable
SalesforceMappableEntityTypes::__construct public function Constructs a new SalesforceMappableEntities object.