You are here

public function NodeOrderListBuilder::buildRow in Node Order 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()

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

File

src/NodeOrderListBuilder.php, line 171

Class

NodeOrderListBuilder
Defines a class to build a listing of node entities.

Namespace

Drupal\nodeorder

Code

public function buildRow(EntityInterface $entity, $weight_delta = 0) {

  /** @var \Drupal\node\NodeInterface $entity */
  $row['title']['data'] = [
    '#type' => 'link',
    '#title' => $entity
      ->label(),
    '#url' => $entity
      ->toUrl(),
  ];

  /** @var \Drupal\node\Entity\NodeType $type */
  $type = $entity->type->entity;
  $row['type'] = [
    '#markup' => $type
      ->label(),
  ];
  $published = $entity
    ->isPublished() ? $this
    ->t('Published') : $this
    ->t('Not published');
  $row['status'] = [
    '#markup' => $published,
  ];
  $row['#attributes']['class'][] = 'draggable';
  $row['#weight'] = $this->nodesWeight[$entity
    ->id()];
  $row['weight'] = [
    '#type' => 'weight',
    '#title' => $this
      ->t('Weight for @title', [
      '@title' => $entity
        ->label(),
    ]),
    '#title_display' => 'invisible',
    '#delta' => $weight_delta,
    '#default_value' => $this->nodesWeight[$entity
      ->id()],
    '#attributes' => [
      'class' => [
        'weight',
      ],
    ],
  ];
  return $row + parent::buildRow($entity);
}