You are here

public function ProviderService::getEntitySynonyms in Synonyms 2.0.x

Retrieve a list of entity synonyms.

Parameters

Drupal\Core\Entity\ContentEntityInterface $entity: Entity for which to conduct the search.

Return value

string[] The array of known synonyms for this entity

File

src/SynonymsService/ProviderService.php, line 59

Class

ProviderService
A collection of handy provider-related methods.

Namespace

Drupal\synonyms\SynonymsService

Code

public function getEntitySynonyms(ContentEntityInterface $entity) {
  $synonyms = [];
  foreach ($this
    ->getSynonymConfigEntities($entity
    ->getEntityTypeId(), $entity
    ->bundle()) as $synonym_config) {
    $synonyms = array_merge($synonyms, $synonym_config
      ->getProviderPluginInstance()
      ->getSynonyms($entity));
  }
  return array_unique($synonyms);
}