You are here

public function SocialPostListBuilder::buildRow in Social Post 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/Controller/SocialPostListBuilder.php \Drupal\social_post\Entity\Controller\SocialPostListBuilder::buildRow()

Parameters

\Drupal\social_post\Entity\SocialPost|Drupal\Core\Entity\EntityTypeInterface $entity: The Social Post entity to render.

Overrides EntityListBuilder::buildRow

File

src/Entity/Controller/SocialPostListBuilder.php, line 102

Class

SocialPostListBuilder
Defines a class to build a listing of Social Post Entities.

Namespace

Drupal\social_post\Entity\Controller

Code

public function buildRow(EntityInterface $entity) {
  $provider = $entity
    ->getPluginId();
  if ($provider == 'social_post_' . $this->provider) {
    $row['provider_user_id'] = $entity
      ->getProviderUserId();

    // Generates (or not) URL to user profile.
    $link = $entity
      ->getLink();
    if ($link && $link
      ->isEmpty()) {
      $row['social_post_name'] = $entity
        ->getName();
    }
    else {
      $row['social_post_name'] = Link::fromTextAndUrl($link->title, $link
        ->getUrl());
    }
    $user = $entity
      ->get('user_id')->entity;
    $row['user'] = $user
      ->toLink();
    return $row + parent::buildRow($entity);
  }
  return [];
}