pm-4.1.x-dev/modules/pm_project/src/PmProjectTypeListBuilder.php

modules/pm_project/src/PmProjectTypeListBuilder.php
<?php

namespace Drupal\pm_project;

use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;

/**
 * Defines a class to build a listing of Project type entities.
 *
 * @see \Drupal\pm_project\Entity\PmProjectType
 */
class PmProjectTypeListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header = [];
    $header['title'] = $this->t('Label');

    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row = [];
    $row['title'] = [
      'data' => $entity->label(),
      'class' => ['menu-label'],
    ];

    return $row + parent::buildRow($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    $build = parent::render();

    $build['table']['#empty'] = $this->t(
      'No Project types available. <a href=":link">Add Project type</a>.',
      [':link' => Url::fromRoute('entity.pm_project_type.add_form')->toString()]
    );

    return $build;
  }

}

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

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