You are here

public function ServerListBuilder::buildRow in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_servers/src/ServerListBuilder.php \Drupal\ldap_servers\ServerListBuilder::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

ldap_servers/src/ServerListBuilder.php, line 37

Class

ServerListBuilder
Provides a listing of Server entities.

Namespace

Drupal\ldap_servers

Code

public function buildRow(EntityInterface $entity) {
  $server = Server::load($entity
    ->id());
  $row = [];
  $row['label'] = $this
    ->getLabel($entity);
  $row['bind_method'] = ucfirst($server
    ->getFormattedBind());
  if ($server
    ->get('bind_method') == 'service_account') {
    $row['binddn'] = $server
      ->get('binddn');
  }
  else {
    $row['binddn'] = $this
      ->t('N/A');
  }
  $row['status'] = $server
    ->get('status') ? 'Yes' : 'No';
  $row['address'] = $server
    ->get('address');
  $row['port'] = $server
    ->get('port');
  $row['current_status'] = $this
    ->checkStatus($server);
  $fields = [
    'bind_method',
    'binddn',
    'status',
    'address',
    'port',
  ];
  foreach ($fields as $field) {
    if ($entity
      ->get($field) != $server
      ->get($field)) {
      $row[$field] .= ' ' . $this
        ->t('(overridden)');
    }
  }
  return $row + parent::buildRow($entity);
}