public function ProfileListBuilder::buildRow in Profile 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/
ProfileListBuilder.php, line 111
Class
- ProfileListBuilder
- List controller for profiles.
Namespace
Drupal\profileCode
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\profile\Entity\ProfileInterface $entity */
$langcode = $entity
->language()
->getId();
$uri = $entity
->toUrl();
$options = $uri
->getOptions();
$options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? [
'language' => $languages[$langcode],
] : [];
$uri
->setOptions($options);
$row['label'] = $entity
->toLink();
$row['type'] = $entity
->bundle();
$row['owner']['data'] = [
'#theme' => 'username',
'#account' => $entity
->getOwner(),
];
$row['status'] = $entity
->isPublished() ? $this
->t('active') : $this
->t('not active');
$row['is_default'] = $entity
->isDefault() ? $this
->t('default') : $this
->t('not default');
$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);
}