You are here

public function LoginDestinationListBuilder::buildRow in Login Destination 8

Same name and namespace in other branches
  1. 8.2 src/Controller/LoginDestinationListBuilder.php \Drupal\login_destination\Controller\LoginDestinationListBuilder::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 DraggableListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

src/Controller/LoginDestinationListBuilder.php, line 49

Class

LoginDestinationListBuilder
Provides a listing of Login Destinations rules.

Namespace

Drupal\login_destination\Controller

Code

public function buildRow(EntityInterface $entity) {

  /** @var LoginDestination $entity */
  $row['label'] = $entity
    ->getLabel();
  if ($entity
    ->isDestinationCurrent()) {
    $row['destination'] = [
      '#markup' => $entity
        ->viewDestination(),
    ];
  }
  else {
    $row['destination'] = [
      '#type' => 'link',
      '#title' => $entity
        ->viewDestination(),
      '#url' => Url::fromUri($entity
        ->getDestination()),
    ];
  }
  $row['triggers'] = [
    '#markup' => $entity
      ->viewTriggers(),
  ];
  $row['pages'] = [
    '#markup' => $entity
      ->viewPages(),
  ];
  $row['language'] = [
    '#markup' => $entity
      ->getLanguage() != "" ? $entity
      ->getLanguage() : $this
      ->t('All languages'),
  ];
  $row['roles'] = [
    '#markup' => $entity
      ->viewRoles(),
  ];
  $row['enabled'] = [
    '#type' => 'checkbox',
    '#default_value' => $entity
      ->isEnabled(),
  ];
  return $row + parent::buildRow($entity);
}