You are here

public function InlineEntityFormComplex::settingsSummary in Inline Entity Form 8

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides InlineEntityFormBase::settingsSummary

File

src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php, line 155

Class

InlineEntityFormComplex
Complex inline widget.

Namespace

Drupal\inline_entity_form\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $labels = $this
    ->getEntityTypeLabels();
  if ($this
    ->getSetting('allow_new')) {
    $summary[] = $this
      ->t('New @label can be added.', [
      '@label' => $labels['plural'],
    ]);
  }
  else {
    $summary[] = $this
      ->t('New @label can not be created.', [
      '@label' => $labels['plural'],
    ]);
  }
  $match_operator_options = $this
    ->getMatchOperatorOptions();
  if ($this
    ->getSetting('allow_existing')) {
    $summary[] = $this
      ->t('Existing @label can be referenced and are matched with the %operator operator.', [
      '@label' => $labels['plural'],
      '%operator' => $match_operator_options[$this
        ->getSetting('match_operator')],
    ]);
  }
  else {
    $summary[] = $this
      ->t('Existing @label can not be referenced.', [
      '@label' => $labels['plural'],
    ]);
  }
  if ($this
    ->getSetting('allow_duplicate')) {
    $summary[] = $this
      ->t('@label can be duplicated.', [
      '@label' => $labels['plural'],
    ]);
  }
  else {
    $summary[] = $this
      ->t('@label can not be duplicated.', [
      '@label' => $labels['plural'],
    ]);
  }
  return $summary;
}