You are here

public function ConfigPagesListBuilder::buildRow in Config Pages 8

Same name and namespace in other branches
  1. 8.3 src/ConfigPagesListBuilder.php \Drupal\config_pages\ConfigPagesListBuilder::buildRow()
  2. 8.2 src/ConfigPagesListBuilder.php \Drupal\config_pages\ConfigPagesListBuilder::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

src/ConfigPagesListBuilder.php, line 59

Class

ConfigPagesListBuilder
Defines a class to build a listing of custom config_pages entities.

Namespace

Drupal\config_pages

Code

public function buildRow(EntityInterface $entity) {
  $row['label'] = $this
    ->getLabel($entity);

  // Used context.
  $contextData = [];
  if (!empty($entity->context['group'])) {
    foreach ($entity->context['group'] as $context_id => $context_enabled) {
      if ($context_enabled) {
        $item = $this->cp_context
          ->getDefinition($context_id);
        $context_value = $item['label'];
        $contextData[] = $context_value;
      }
    }
  }
  $row['context'] = implode(', ', $contextData);
  return $row + parent::buildRow($entity);
}