You are here

function _civicrm_entity_field_get_entity_type_storage in CiviCRM Entity 8.3

Determines whether the entity type the field appears in is CiviCRM based.

Overridden version of _views_field_get_entity_type_storage to support the CiviCRM Entity storage.

Parameters

\Drupal\field\FieldStorageConfigInterface $field_storage: The field storage definition.

Return value

\Drupal\civicrm_entity\CiviEntityStorage|bool Returns the entity type storage if supported.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

See also

_views_field_get_entity_type_storage()

2 calls to _civicrm_entity_field_get_entity_type_storage()
civicrm_entity_field_default_views_data in ./civicrm_entity.views.inc
Overridden function to support custom storage.
civicrm_entity_views_data_alter in ./civicrm_entity.views.inc
Implements hook_views_data_alter().

File

./civicrm_entity.views.inc, line 82

Code

function _civicrm_entity_field_get_entity_type_storage(FieldStorageConfigInterface $field_storage) {
  $result = FALSE;
  $entity_type_manager = \Drupal::entityTypeManager();
  if ($entity_type_manager
    ->hasDefinition($field_storage
    ->getTargetEntityTypeId())) {
    $storage = $entity_type_manager
      ->getStorage($field_storage
      ->getTargetEntityTypeId());
    $result = $storage instanceof CiviEntityStorage ? $storage : FALSE;
  }
  return $result;
}