You are here

public function FlagMappingListBuilder::buildRow in Flags 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/FlagMappingListBuilder.php, line 70

Class

FlagMappingListBuilder
Provides a listing of flag mapping entities.

Namespace

Drupal\flags\Entity

Code

public function buildRow(EntityInterface $entity) {

  // Unfortunately countries are indexed with uppercase letters
  // se we make sure our ids are correct.

  /** @var FlagMapping $entity */
  $id = strtoupper($entity
    ->getSource());
  $row['country'] = isset($this->countries[$id]) ? $this->countries[$id] : $id;
  $row['flag']['data'] = [
    '#theme' => 'flags',
    '#code' => strtolower($entity
      ->getFlag()),
    '#source' => 'country',
  ];
  $row['info'] = $this->flags[$entity
    ->getFlag()];
  return $row + parent::buildRow($entity);
}