BrokenLinkListBuilder.php in Broken Link 8.3
File
src/BrokenLinkListBuilder.php
View source
<?php
namespace Drupal\broken_link;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
class BrokenLinkListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['link'] = $this
->t('Broken link');
$header['hits'] = $this
->t('Hits');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
foreach ([
'link',
'hits',
] as $column) {
if ($entity
->get($column)
->get(0)) {
$row[$column] = $entity
->get($column)
->get(0)
->getValue()['value'];
}
else {
$row[$column] = '';
}
}
return $row + parent::buildRow($entity);
}
protected function getEntityIds() {
$query = $this
->getStorage()
->getQuery()
->sort('hits', 'DESC');
if ($this->limit) {
$query
->pager($this->limit);
}
return $query
->execute();
}
}