You are here

RelationTypeListBuilder.php in Relation 8.2

Same filename and directory in other branches
  1. 8 src/RelationTypeListBuilder.php

Namespace

Drupal\relation

File

src/RelationTypeListBuilder.php
View source
<?php

/**
 * @file
 * Contains \Drupal\relation\RelationTypeListBuilder.
 */
namespace Drupal\relation;

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

/**
 * Provides a listing of relation types.
 */
class RelationTypeListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['title'] = t('Name');
    return $header + parent::buildHeader();
  }

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

  /**
   * {@inheritdoc}
   */
  public function render() {
    $build = parent::render();
    $build['#empty'] = t('No relation types exist. <a href="@link">Add relation type</a>.', array(
      '@link' => Url::fromRoute('entity.relation_type.add_form'),
    ));
    return $build;
  }

}

Classes

Namesort descending Description
RelationTypeListBuilder Provides a listing of relation types.