You are here

public function SelectService::getSynonyms in Synonyms 8

Extract a list of synonyms from an entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Entity from which to extract the synonyms.

Return value

array Array of synonyms. Each sub array will have the following structure:

  • synonym: (string) Synonym itself
  • wording: (string) Formatted wording with which this synonym should be presented to the end user

File

src/SynonymsService/Behavior/SelectService.php, line 105

Class

SelectService
Synonyms behavior service for select widget.

Namespace

Drupal\synonyms\SynonymsService\Behavior

Code

public function getSynonyms(ContentEntityInterface $entity) {
  $synonyms = $this
    ->getSynonymsMultiple([
    $entity
      ->id() => $entity,
  ]);
  return $synonyms[$entity
    ->id()];
}