ExternalLinkPopupListBuilder.php in External Link Pop-up 8
File
src/Controller/ExternalLinkPopupListBuilder.php
View source
<?php
namespace Drupal\external_link_popup\Controller;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
class ExternalLinkPopupListBuilder extends DraggableListBuilder {
public function buildHeader() {
$header['label'] = $this
->t('Name');
$header['id'] = $this
->t('Machine name');
$header['domains'] = $this
->t('Domains');
$header['status'] = $this
->t('Status');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['id']['#markup'] = $entity
->id();
$row['domains']['#markup'] = $entity
->getDomains() ? preg_replace("/\\s*\n\\s*/", ', ', $entity
->getDomains()) : '';
if ($entity
->status()) {
$row['status']['#markup'] = $this
->t('Enabled');
}
else {
$row['status']['#markup'] = $this
->t('Disabled');
}
return $row + parent::buildRow($entity);
}
public function getFormId() {
return 'external_link_popup_entity_list_form';
}
}