You are here

public function EntityReference::getSummary in Feeds 8.3

Returns the summary for a target.

Returning the summary as array is encouraged. The allowance of returning a string only exists for backwards compatibility.

Return value

string|string[] The configuration summary.

Overrides FieldTargetBase::getSummary

1 call to EntityReference::getSummary()
File::getSummary in src/Feeds/Target/File.php
Returns the summary for a target.
1 method overrides EntityReference::getSummary()
File::getSummary in src/Feeds/Target/File.php
Returns the summary for a target.

File

src/Feeds/Target/EntityReference.php, line 441

Class

EntityReference
Defines an entity reference mapper.

Namespace

Drupal\feeds\Feeds\Target

Code

public function getSummary() {
  $options = $this
    ->getPotentialFields();
  $summary = parent::getSummary();
  if ($this->configuration['reference_by'] && isset($options[$this->configuration['reference_by']])) {
    $summary[] = $this
      ->t('Reference by: %message', [
      '%message' => $options[$this->configuration['reference_by']],
    ]);
    if ($this->configuration['reference_by'] == 'feeds_item') {
      $feed_item_options = $this
        ->getFeedsItemOptions();
      $summary[] = $this
        ->t('Feed item: %feed_item', [
        '%feed_item' => $feed_item_options[$this->configuration['feeds_item']],
      ]);
    }
  }
  else {
    $summary[] = [
      '#prefix' => '<div class="messages messages--warning">',
      '#markup' => $this
        ->t('Please select a field to reference by.'),
      '#suffix' => '</div>',
    ];
  }
  if ($this->configuration['reference_by'] === $this
    ->getLabelKey()) {
    $create = $this->configuration['autocreate'] ? $this
      ->t('Yes') : $this
      ->t('No');
    $summary[] = $this
      ->t('Autocreate terms: %create', [
      '%create' => $create,
    ]);
  }
  return $summary;
}