public function SimpleSitemapListBuilder::buildRow in Simple XML sitemap 4.x
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 DraggableListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- src/
SimpleSitemapListBuilder.php, line 40
Class
- SimpleSitemapListBuilder
- Class SimpleSitemapListBuilder
Namespace
Drupal\simple_sitemapCode
public function buildRow(EntityInterface $entity) {
$row['name']['#markup'] = '<span title="' . $this
->t((string) $entity
->get('description')) . '">' . $this
->t($entity
->label()) . '</span>';
$row['type']['#markup'] = '<span title="' . $this
->t((string) $entity
->getType()
->get('description')) . '">' . $this
->t($entity
->getType()
->label()) . '</span>';
$row['status']['#markup'] = $this
->t('pending');
$row['count']['#markup'] = '';
/** @var \Drupal\simple_sitemap\Entity\SimpleSitemapInterface $entity */
if (!empty($entity
->fromPublishedAndUnpublished()
->getChunkCount())) {
switch ($entity
->contentStatus()) {
case SimpleSitemap::SITEMAP_UNPUBLISHED:
$row['status']['#markup'] = $this
->t('generating');
break;
case SimpleSitemap::SITEMAP_PUBLISHED:
case SimpleSitemap::SITEMAP_PUBLISHED_GENERATING:
$row['name']['#markup'] = '<a title ="' . $this
->t((string) $entity
->get('description')) . '" href="' . $entity
->toUrl()
->toString() . '" target="_blank">' . $this
->t($entity
->label()) . '</a>';
$row['status']['#markup'] = $this
->t($entity
->contentStatus() === SimpleSitemap::SITEMAP_PUBLISHED ? 'published on @time' : 'published on @time, regenerating', [
'@time' => \Drupal::service('date.formatter')
->format($entity
->fromPublished()
->getCreated()),
]);
$row['count']['#markup'] = $entity
->fromPublished()
->getLinkCount();
break;
}
}
return $row + parent::buildRow($entity);
}