You are here

public static function DynamicEntityReferenceItem::defaultFieldSettings 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::defaultFieldSettings()

Defines the field-level settings for this plugin.

Return value

array A list of default settings, keyed by the setting name.

Overrides EntityReferenceItem::defaultFieldSettings

File

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

Class

DynamicEntityReferenceItem
Defines the 'dynamic_entity_reference' entity field type.

Namespace

Drupal\dynamic_entity_reference\Plugin\Field\FieldType

Code

public static function defaultFieldSettings() {
  $default_settings = [];
  $labels = \Drupal::service('entity_type.repository')
    ->getEntityTypeLabels(TRUE);
  $options = $labels[(string) t('Content', [], [
    'context' => 'Entity type group',
  ])];

  // Field storage settings are not accessible here so we are assuming that
  // all the entity types are referenceable by default.
  // See https://www.drupal.org/node/2346273#comment-9385179 for more details.
  foreach (array_keys($options) as $entity_type_id) {
    $default_settings[$entity_type_id] = [
      'handler' => "default:{$entity_type_id}",
      'handler_settings' => [],
    ];
  }
  return $default_settings;
}