EntityformTypeListBuilder.php in Entityform 8.3        
                          
                  
                        
  
  
  
  
File
  src/EntityformTypeListBuilder.php
  
    View source  
  <?php
namespace Drupal\entityform;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Utility\Xss;
use Drupal\Component\Utility\String;
class EntityformTypeListBuilder extends ConfigEntityListBuilder {
  
  protected $urlGenerator;
  
  public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, UrlGeneratorInterface $url_generator) {
    parent::__construct($entity_type, $storage);
    $this->urlGenerator = $url_generator;
  }
  
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static($entity_type, $container
      ->get('entity.manager')
      ->getStorage($entity_type
      ->id()), $container
      ->get('url_generator'));
  }
  
  public function buildHeader() {
    $header['title'] = t('Name');
    $header['description'] = array(
      'data' => t('Description'),
      'class' => array(
        RESPONSIVE_PRIORITY_MEDIUM,
      ),
    );
    return $header + parent::buildHeader();
  }
  
  public function buildRow(EntityInterface $entity) {
    $row['title'] = array(
      'data' => $this
        ->getLabel($entity),
      'class' => array(
        'menu-label',
      ),
    );
    
    return $row + parent::buildRow($entity);
  }
  
  public function getDefaultOperations(EntityInterface $entity) {
    $operations = parent::getDefaultOperations($entity);
    
    if (isset($operations['edit'])) {
      $operations['edit']['weight'] = 30;
    }
    return $operations;
  }
  
  public function render() {
    $build = parent::render();
    $build['#empty'] = t('No entityform types available. <a href="@link">Add Entityform type</a>.', array(
      '@link' => $this->urlGenerator
        ->generateFromPath('admin/structure/entityform_types/add'),
    ));
    return $build;
  }
}