You are here

public static function PreviewLink::entitiesDefaultFieldSettings in Preview Link 2.x

Same name and namespace in other branches
  1. 2.0.x src/Entity/PreviewLink.php \Drupal\preview_link\Entity\PreviewLink::entitiesDefaultFieldSettings()

Rewrites settings for 'entities' dynamic_entity_reference field.

DynamicEntityReferenceItem::defaultFieldSettings doesnt receive any context so we need to change the default handlers manually.

File

src/Entity/PreviewLink.php, line 147

Class

PreviewLink
Defines the node entity class.

Namespace

Drupal\preview_link\Entity

Code

public static function entitiesDefaultFieldSettings() : array {
  $labels = \Drupal::service('entity_type.repository')
    ->getEntityTypeLabels(TRUE);
  $options = $labels[(string) t('Content', [], [
    'context' => 'Entity type group',
  ])];
  $settings = [
    'exclude_entity_types' => TRUE,
    'entity_type_ids' => [],
  ];
  $settings += array_fill_keys(array_keys($options), [
    'handler' => 'preview_link',
    'handler_settings' => [],
  ]);
  return $settings;
}