You are here

OrganizationListBuilder.php in Drupal PM (Project Management) 4.x

File

modules/pm_organization/src/OrganizationListBuilder.php
View source
<?php

namespace Drupal\pm_organization;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;

/**
 * Defines a class to build a listing of Organization entities.
 *
 * @ingroup pm_organization
 */
class OrganizationListBuilder extends EntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['id'] = $this
      ->t('Organization ID');
    $header['name'] = $this
      ->t('Name');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {

    /** @var \Drupal\pm_organization\Entity\Organization $entity */
    $row['id'] = $entity
      ->id();
    $row['name'] = Link::createFromRoute($entity
      ->label(), 'entity.pm_organization.edit_form', [
      'pm_organization' => $entity
        ->id(),
    ]);
    return $row + parent::buildRow($entity);
  }

}

Classes

Namesort descending Description
OrganizationListBuilder Defines a class to build a listing of Organization entities.