You are here

public static function DynamicEntityReferenceItem::getTargetTypes in Dynamic Entity Reference 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem::getTargetTypes()

Helper function to get all the entity type ids that can be referenced.

Parameters

array $settings: The settings of the field storage.

Return value

string[] All the target entity type ids that can be referenced.

14 calls to DynamicEntityReferenceItem::getTargetTypes()
DynamicEntityReferenceEntityFormatter::settingsForm in src/Plugin/Field/FieldFormatter/DynamicEntityReferenceEntityFormatter.php
Returns a form to configure settings for the formatter.
DynamicEntityReferenceEntityFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/DynamicEntityReferenceEntityFormatter.php
Returns a short summary for the current formatter settings.
DynamicEntityReferenceItem::calculateDependencies in src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php
Calculates dependencies for field items.
DynamicEntityReferenceItem::calculateStorageDependencies in src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php
Calculates dependencies for field items on the storage level.
DynamicEntityReferenceItem::fieldSettingsForm in src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php
Returns a form for the field-level settings.

... See full list

File

src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php, line 649

Class

DynamicEntityReferenceItem
Defines the 'dynamic_entity_reference' entity field type.

Namespace

Drupal\dynamic_entity_reference\Plugin\Field\FieldType

Code

public static function getTargetTypes(array $settings) {
  $labels = \Drupal::service('entity_type.repository')
    ->getEntityTypeLabels(TRUE);
  $options = array_filter(array_keys($labels[(string) t('Content', [], [
    'context' => 'Entity type group',
  ])]), function ($entity_type_id) {
    return static::entityHasIntegerId($entity_type_id);
  });
  if (!empty($settings['exclude_entity_types'])) {
    return array_diff($options, $settings['entity_type_ids'] ?: []);
  }
  else {
    return array_intersect($options, $settings['entity_type_ids'] ?: []);
  }
}