You are here

public function FlipbookListBuilder::buildRow in 3D Flipbook 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/Entity/Controller/FlipbookListBuilder.php, line 56

Class

FlipbookListBuilder
Provides a list controller for content_entity_example_contact entity.

Namespace

Drupal\flipbook\Entity\Controller

Code

public function buildRow(EntityInterface $entity) {
  $row['id'] = $entity
    ->id();
  $row['name'] = $entity
    ->link();
  $fid = $entity->flipbook_cover->target_id;
  $pid = $entity->flipbook->target_id;
  $file = File::load($fid);
  $pfile = File::load($pid);
  $path = $file
    ->getFileUri();
  $pdfpath = file_create_url($pfile
    ->getFileUri());
  $fname = $file
    ->getFilename();
  $pname = $pfile
    ->getFilename();
  $url = ImageStyle::load('large')
    ->buildUrl($path);
  $row['flipbook_cover'] = Markup::create('<a href=' . $url . ' target="_blank">' . $fname . '</a>');
  $row['flipbook'] = Markup::create('<a href=' . $pdfpath . ' target="_blank">' . $pname . '</a>');
  return $row + parent::buildRow($entity);
}