You are here

public function ProfileListBuilder::buildRow in Profile 2 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/ProfileListBuilder.php, line 91
Contains \Drupal\profile\ProfileListController.

Class

ProfileListBuilder
List controller for profiles.

Namespace

Drupal\profile

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\profile\ProfileInterface $entity */
  $mark = array(
    '#theme' => 'mark',
    '#mark_type' => node_mark($entity
      ->id(), $entity
      ->getChangedTime()),
  );
  $langcode = $entity
    ->language()->id;
  $uri = $entity
    ->urlInfo();
  $options = $uri
    ->getOptions();
  $options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array(
    'language' => $languages[$langcode],
  ) : array();
  $uri
    ->setOptions($options);
  $row['label']['data'] = array(
    '#type' => 'link',
    '#title' => $entity
      ->label(),
    '#suffix' => ' ' . drupal_render($mark),
  ) + $uri
    ->toRenderArray();
  $row['type'] = $entity
    ->getType()
    ->id();
  $row['owner']['data'] = array(
    '#theme' => 'username',
    '#account' => $entity
      ->getOwner(),
  );
  $row['status'] = $entity
    ->isActive() ? $this
    ->t('active') : $this
    ->t('not active');
  $row['changed'] = $this->dateFormatter
    ->format($entity
    ->getChangedTime(), 'short');
  $language_manager = \Drupal::languageManager();
  if ($language_manager
    ->isMultilingual()) {
    $row['language_name'] = $language_manager
      ->getLanguageName($langcode);
  }
  $route_params = array(
    'user' => $entity
      ->getOwnerId(),
    'type' => $entity
      ->bundle(),
    'profile' => $entity
      ->id(),
  );
  $links['edit'] = array(
    'title' => t('Edit'),
    'route_name' => 'entity.profile.edit_form',
    'route_parameters' => $route_params,
  );
  $links['delete'] = array(
    'title' => t('Delete'),
    'route_name' => 'entity.profile.delete_form',
    'route_parameters' => $route_params,
  );
  $row[] = array(
    'data' => array(
      '#type' => 'operations',
      '#links' => $links,
    ),
  );
  return $row + parent::buildRow($entity);
}