htools-8.x-1.x-dev/modules/htools_relations/src/RelationalEntityListBuilder.php

modules/htools_relations/src/RelationalEntityListBuilder.php
<?php

namespace Drupal\htools_relations;

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

/**
 * Defines a class to build a listing of Relational entity entities.
 *
 * @ingroup htools_relations
 */
class RelationalEntityListBuilder extends EntityListBuilder {

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

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    /* @var \Drupal\htools_relations\Entity\RelationalEntity $entity */
    $row['id'] = $entity->id();
    $row['name'] = Link::createFromRoute(
      $entity->label(),
      'entity.relational_entity.edit_form',
      ['relational_entity' => $entity->id()]
    );
    return $row + parent::buildRow($entity);
  }

}

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

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