You are here

public function PostListBuilder::buildRow in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  2. 8 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  3. 8.2 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  4. 8.3 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  5. 8.4 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  6. 8.5 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  7. 8.6 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  8. 8.7 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  9. 8.8 modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  10. 10.3.x modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  11. 10.0.x modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()
  12. 10.1.x modules/social_features/social_post/src/PostListBuilder.php \Drupal\social_post\PostListBuilder::buildRow()

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

modules/social_features/social_post/src/PostListBuilder.php, line 32

Class

PostListBuilder
Defines a class to build a listing of Post entities.

Namespace

Drupal\social_post

Code

public function buildRow(EntityInterface $entity) {
  $row = [];

  /** @var \Drupal\social_post\Entity\Post $entity */
  $row['id'] = $entity
    ->id();
  $row['post'] = '';
  if ($entity
    ->hasField('field_post')) {
    $post_value = $entity
      ->get('field_post')->value;
    $row['post'] = text_summary($post_value, NULL, 120);
  }
  $row['author'] = $entity
    ->getOwner()
    ->toLink();
  $row['created'] = \Drupal::service('date.formatter')
    ->format($entity
    ->getCreatedTime(), 'small');
  $row['status'] = $entity
    ->isPublished() ? t("published") : t("unpublished");
  return $row + parent::buildRow($entity);
}