public function EntityReferenceField::getSynonyms in Synonyms 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Synonyms/Provider/EntityReferenceField.php \Drupal\synonyms\Plugin\Synonyms\Provider\EntityReferenceField::getSynonyms()
Fetch synonyms from an entity.
Parameters
Drupal\Core\Entity\ContentEntityInterface $entity: Entity whose synonyms should be fetched.
Return value
string[] Array of extracted synonyms
Overrides SynonymsGetTrait::getSynonyms
File
- src/
Plugin/ Synonyms/ Provider/ EntityReferenceField.php, line 82
Class
- EntityReferenceField
- Provide synonyms from entity reference field type.
Namespace
Drupal\synonyms\Plugin\Synonyms\ProviderCode
public function getSynonyms(ContentEntityInterface $entity) {
$synonyms = [];
foreach ($entity
->get($this
->getPluginDefinition()['field']) as $item) {
$synonyms[] = $item->entity
->label();
}
return $synonyms;
}