public function EntityReferenceField::getSynonyms in Synonyms 2.0.x
Same name and namespace in other branches
- 8 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 GetInterface::getSynonyms
File
- src/
Plugin/ Synonyms/ Provider/ EntityReferenceField.php, line 77
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) {
if (!$item
->isEmpty()) {
$synonyms[] = $item->entity
->label();
}
}
return $synonyms;
}