You are here

public static function RecordType::isAllowed in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RecordType.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\RecordType::isAllowed()
  2. 8.3 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RecordType.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\RecordType::isAllowed()

Determine whether this plugin is allowed for a given mapping.

Given a SF Mapping, return TRUE or FALSE whether this field plugin can be added via UI. Not used for validation or any other constraints. This works like a soft dependency.

Parameters

\Drupal\salesforce_mapping\Entity\SalesforceMappingInterface $mapping: The mapping.

Return value

bool TRUE if the field plugin can be added to this mapping.

Overrides SalesforceMappingFieldPluginBase::isAllowed

See also

\Drupal\salesforce_mapping\Plugin\SalesforceMappingField\Broken

File

modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RecordType.php, line 74

Class

RecordType
Adapter for entity properties and fields.

Namespace

Drupal\salesforce_mapping\Plugin\SalesforceMappingField

Code

public static function isAllowed(SalesforceMappingInterface $mapping) {
  try {
    $record_types = self::client()
      ->getRecordTypes($mapping
      ->getSalesforceObjectType());
    if ($record_types === FALSE) {
      return FALSE;
    }
    return count($record_types) > 1;
  } catch (\Exception $e) {
    return FALSE;
  }
}