You are here

public function ContactListBuilder::buildRow in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 content_entity_example/src/Entity/Controller/ContactListBuilder.php \Drupal\content_entity_example\Entity\Controller\ContactListBuilder::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/content_entity_example/src/Entity/Controller/ContactListBuilder.php, line 88

Class

ContactListBuilder
Provides a list controller for content_entity_example entity.

Namespace

Drupal\content_entity_example\Entity\Controller

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\content_entity_example\Entity\Contact */
  $row['id'] = $entity
    ->id();
  $row['name'] = $entity
    ->toLink()
    ->toString();
  $row['first_name'] = $entity->first_name->value;
  $row['role'] = $entity->role->value;
  return $row + parent::buildRow($entity);
}