You are here

public function TranslatorListBuilder::buildRow in Translation Management Tool 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 DraggableListBuilder::buildRow

See also

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

File

src/Entity/ListBuilder/TranslatorListBuilder.php, line 103

Class

TranslatorListBuilder
Provides a listing of translators.

Namespace

Drupal\tmgmt\Entity\ListBuilder

Code

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

  // Add provider logo.

  /** @var \Drupal\tmgmt\Entity\Translator $entity */
  $definition = \Drupal::service('plugin.manager.tmgmt.translator')
    ->getDefinition($entity
    ->getPluginId());
  if (isset($definition['logo'])) {
    $logo_render_array = [
      '#theme' => 'image',
      '#uri' => file_create_url(drupal_get_path('module', $definition['provider']) . '/' . $definition['logo']),
      '#alt' => $definition['label'],
      '#title' => $definition['label'],
      '#attributes' => [
        'class' => 'tmgmt-logo-overview',
      ],
    ];
  }
  $row['logo'] = isset($logo_render_array) ? $logo_render_array : [
    '#markup' => $definition['label'],
  ];
  return $row + parent::buildRow($entity);
}