BrokenLinkListBuilder.php in Broken Link 8
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) {
$row['link'] = $entity
->get('link')
->get(0)
->getValue()['value'];
$row['hits'] = $entity
->get('hits')
->get(0)
->getValue()['value'];
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();
}
}