pm-4.1.x-dev/src/PmStatusPriorityListBuilder.php

src/PmStatusPriorityListBuilder.php
<?php

namespace Drupal\pm;

use Drupal\Core\Entity\EntityInterface;

/**
 * Provides a list controller for the Project entity type.
 */
abstract class PmStatusPriorityListBuilder extends PmListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader(): array {
    $header = [];
    $header['id'] = $this->t('ID');
    $header['label'] = $this->t('Label');
    $header['uid'] = $this->t('Creator');
    $header['status'] = $this->t('Status');
    $header['priority'] = $this->t('Priority');
    $header['created'] = $this->t('Created');
    $header['changed'] = $this->t('Updated');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row = [];
    /** @var \Drupal\pm_project\PmProjectInterface $entity */
    $row['id'] = $entity->id();
    $row['label'] = $entity->toLink();
    $row['uid']['data'] = [
      '#theme' => 'username',
      '#account' => $entity->getOwner(),
    ];
    $component_settings = [
      'type' => 'pm_pmui_pills',
      'label' => 'hidden',
    ];
    $row['status']['data'] = $this->viewBuilder->viewField($entity->get('pm_status'), $component_settings);
    $row['priority']['data'] = $this->viewBuilder->viewField($entity->get('pm_priority'), $component_settings);
    $row['created'] = $this->dateFormatter->format($entity->get('created')->value, 'short');
    $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');
    return $row + parent::buildRow($entity);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc