openquestions-1.0.x-dev/src/List/OqItemTypeListBuilder.php
src/List/OqItemTypeListBuilder.php
<?php
namespace Drupal\openquestions\List;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
/**
* Defines a class to build a listing of oq item type entities.
*
* @see \Drupal\openquestions\Entity\OqItemType
*/
class OqItemTypeListBuilder extends ConfigEntityListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['title'] = $this->t('Label');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$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 oq item types available. <a href=":link">Add oq item type</a>.',
[':link' => Url::fromRoute('entity.oq_item_type.add_form')->toString()]
);
return $build;
}
}
