public function SynonymListBuilder::buildRow in Search API Synonym 8
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- src/
SynonymListBuilder.php, line 89
Class
- SynonymListBuilder
- Defines a class to build a listing of Synonym entities.
Namespace
Drupal\search_api_synonymCode
public function buildRow(EntityInterface $entity) {
$langcode = $entity
->language()
->getId();
/* @var $entity \Drupal\search_api_synonym\Entity\Synonym */
$row['word'] = $this
->buildEditLink($entity
->label(), $entity);
$row['synonyms'] = $this
->buildEditLink($entity
->getSynonyms(), $entity);
$row['author']['data'] = [
'#theme' => 'username',
'#account' => $entity
->getOwner(),
];
$row['status'] = $entity
->isActive() ? $this
->t('active') : $this
->t('inactive');
$row['changed'] = $this->dateFormatter
->format($entity
->getChangedTime(), 'short');
$language_manager = \Drupal::languageManager();
if ($language_manager
->isMultilingual()) {
$row['language_name'] = $language_manager
->getLanguageName($langcode);
}
return $row + parent::buildRow($entity);
}