You are here

public function BlockVisibilityGroupListBuilder::buildRow in Block Visibility Groups 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/Controller/BlockVisibilityGroupListBuilder.php, line 28

Class

BlockVisibilityGroupListBuilder
Provides a listing of Block Visibility Group entities.

Namespace

Drupal\block_visibility_groups\Controller

Code

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

  // You probably want a few more properties here...
  $row += parent::buildRow($entity);
  $url = Url::fromRoute('block.admin_display', [], [
    'query' => [
      'block_visibility_group' => $row['id'],
    ],
  ]);

  /*$row['manage_blocks'] = array(
      '#type' => 'link',
      '#title' => 'Manage Blocks',
      // @todo Why does this crash?
      '#url' => $url,

      ); */
  $row['operations']['data']['#links']['manage_blocks'] = [
    'title' => $this
      ->t('Manage Blocks'),
    'weight' => 80,
    'url' => $url,
  ];
  uasort($row['operations']['data']['#links'], '\\Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
  return $row;
}