ActivityListBuilder.php in CRM Core 8.2
File
modules/crm_core_activity/src/ActivityListBuilder.php
View source
<?php
namespace Drupal\crm_core_activity;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ActivityListBuilder extends EntityListBuilder {
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage) {
parent::__construct($entity_type, $storage);
}
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container
->get('entity_type.manager')
->getStorage($entity_type
->id()));
}
public function buildHeader() {
$header = array();
$header['date'] = $this
->t('Activity Date');
$header['title'] = $this
->t('Title');
$header['type'] = $this
->t('Activity type');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row = array();
$row['date']['data'] = $entity
->get('activity_date')
->view(array(
'label' => 'hidden',
));
$row['title']['data'] = array(
'#type' => 'link',
'#title' => $entity
->label(),
'#url' => $entity
->urlInfo(),
);
$row['type'] = $entity
->get('type')->entity
->label();
return $row + parent::buildRow($entity);
}
public function render() {
$build = parent::render();
$build['table']['#empty'] = $this
->t('There are no activities available.');
return $build;
}
}