function NodeListBuilder::buildRow
Same name in other branches
- 9 core/modules/node/src/NodeListBuilder.php \Drupal\node\NodeListBuilder::buildRow()
- 10 core/modules/node/src/NodeListBuilder.php \Drupal\node\NodeListBuilder::buildRow()
- 11.x core/modules/node/src/NodeListBuilder.php \Drupal\node\NodeListBuilder::buildRow()
Overrides EntityListBuilder::buildRow
1 call to NodeListBuilder::buildRow()
- ModeratedNodeListBuilder::buildRow in core/
modules/ content_moderation/ src/ ModeratedNodeListBuilder.php - Builds a row for an entity in the entity listing.
1 method overrides NodeListBuilder::buildRow()
- ModeratedNodeListBuilder::buildRow in core/
modules/ content_moderation/ src/ ModeratedNodeListBuilder.php - Builds a row for an entity in the entity listing.
File
-
core/
modules/ node/ src/ NodeListBuilder.php, line 92
Class
- NodeListBuilder
- Defines a class to build a listing of node entities.
Namespace
Drupal\nodeCode
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\node\NodeInterface $entity */
$mark = [
'#theme' => 'mark',
'#mark_type' => node_mark($entity->id(), $entity->getChangedTime()),
];
$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['title']['data'] = [
'#type' => 'link',
'#title' => $entity->label(),
'#suffix' => ' ' . \Drupal::service('renderer')->render($mark),
'#url' => $uri,
];
$row['type'] = node_get_type_label($entity);
$row['author']['data'] = [
'#theme' => 'username',
'#account' => $entity->getOwner(),
];
$row['status'] = $entity->isPublished() ? $this->t('published') : $this->t('not published');
$row['changed'] = $this->dateFormatter
->format($entity->getChangedTime(), 'short');
$language_manager = \Drupal::languageManager();
if ($language_manager->isMultilingual()) {
$row['language_name'] = $language_manager->getLanguageName($langcode);
}
$row['operations']['data'] = $this->buildOperations($entity);
return $row + parent::buildRow($entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.