You are here

public function Entity::settingsSummary in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/DsField/Entity.php \Drupal\ds\Plugin\DsField\Entity::settingsSummary()
  2. 8.3 src/Plugin/DsField/Entity.php \Drupal\ds\Plugin\DsField\Entity::settingsSummary()

Returns the summary of the chosen settings.

Parameters

array $settings: Contains the settings of the field.

Return value

array A render array containing the summary.

Overrides DsFieldBase::settingsSummary

File

src/Plugin/DsField/Entity.php, line 68

Class

Entity
Renders an entity by a given view mode.

Namespace

Drupal\ds\Plugin\DsField

Code

public function settingsSummary($settings) {
  $entity = $this
    ->linkedEntity();
  $view_modes = $this->entityDisplayRepository
    ->getViewModes($entity);

  // When no view modes are found no summary is displayed.
  if (empty($view_modes)) {
    return [];
  }

  // Print the chosen view mode or the default one.
  $config = $this
    ->getConfiguration();
  $entity_view_mode = $config['entity_view_mode'];
  $summary[] = 'View mode: ' . $view_modes[$entity_view_mode]['label'];
  return $summary;
}