You are here

public function YamlFormEntityListBuilder::buildRow in YAML Form 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/YamlFormEntityListBuilder.php, line 161

Class

YamlFormEntityListBuilder
Defines a class to build a listing of form entities.

Namespace

Drupal\yamlform

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\yamlform\YamlFormInterface */
  $settings = $entity
    ->getSettings();

  // ISSUE: Forms that the current user can't access are not being hidden via the EntityQuery.
  // WORK-AROUND: Don't link to the form.
  // See: Access control is not applied to config entity queries
  // https://www.drupal.org/node/2636066
  $row['title']['data']['title'] = [
    '#markup' => $entity
      ->access('view') ? $entity
      ->toLink()
      ->toString() : $entity
      ->label(),
  ];
  if ($entity
    ->isTemplate()) {
    $row['title']['data']['template'] = [
      '#markup' => ' <b>(' . $this
        ->t('Template') . ')</b>',
    ];
  }
  $row['description']['data']['description']['#markup'] = $entity
    ->get('description');
  $row['status'] = $entity
    ->isOpen() ? $this
    ->t('Open') : $this
    ->t('Closed');
  $row['owner'] = ($owner = $entity
    ->getOwner()) ? $owner
    ->toLink() : '';
  $row['results_total'] = $this->submissionStorage
    ->getTotal($entity) . (!empty($settings['results_disabled']) ? ' ' . $this
    ->t('(Disabled)') : '');
  $row['results_operations']['data'] = [
    '#type' => 'operations',
    '#links' => $this
      ->getDefaultOperations($entity, 'results'),
  ];
  return $row + parent::buildRow($entity);
}