You are here

public function PriceListListBuilder::buildRow in Commerce Pricelist 8.2

Same name and namespace in other branches
  1. 8 src/PriceListListBuilder.php \Drupal\commerce_pricelist\PriceListListBuilder::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()

1 call to PriceListListBuilder::buildRow()
PriceListListBuilder::buildForm in src/PriceListListBuilder.php
Form constructor.

File

src/PriceListListBuilder.php, line 105

Class

PriceListListBuilder
Defines the list builder for price lists.

Namespace

Drupal\commerce_pricelist

Code

public function buildRow(EntityInterface $entity) {

  /* @var \Drupal\commerce_pricelist\Entity\PriceListInterface $entity */
  $row['#attributes']['class'][] = 'draggable';
  $row['#weight'] = $entity
    ->getWeight();
  $row['name'] = $entity
    ->label();
  if (!$entity
    ->isEnabled()) {
    $row['name'] .= ' (' . $this
      ->t('Disabled') . ')';
  }
  $row['start_date'] = $entity
    ->getStartDate()
    ->format('M jS Y H:i:s');
  $row['end_date'] = $entity
    ->getEndDate() ? $entity
    ->getEndDate()
    ->format('M jS Y H:i:s') : '—';
  if ($this->hasTableDrag) {
    $row['weight'] = [
      '#type' => 'weight',
      '#title' => $this
        ->t('Weight for @title', [
        '@title' => $entity
          ->label(),
      ]),
      '#title_display' => 'invisible',
      '#default_value' => $entity
        ->getWeight(),
      '#attributes' => [
        'class' => [
          'weight',
        ],
      ],
    ];
  }
  return $row + parent::buildRow($entity);
}