CurrencyListBuilder.php in Currency 8.3
File
src/Entity/Currency/CurrencyListBuilder.php
View source
<?php
namespace Drupal\currency\Entity\Currency;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CurrencyListBuilder extends ConfigEntityListBuilder {
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $entity_storage, TranslationInterface $string_translation, ModuleHandlerInterface $module_handler) {
parent::__construct($entity_type, $entity_storage);
$this->moduleHandler = $module_handler;
$this->stringTranslation = $string_translation;
}
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
$entity_type_manager = $container
->get('entity_type.manager');
return new static($entity_type, $entity_type_manager
->getStorage('currency'), $container
->get('string_translation'), $container
->get('module_handler'));
}
public function buildHeader() {
$header = array(
'id' => $this
->t('Currency code'),
'label' => $this
->t('Name'),
) + parent::buildHeader();
return $header;
}
public function buildRow(EntityInterface $entity) {
$row = array(
'id' => $entity
->id(),
'label' => $entity
->label(),
) + parent::buildRow($entity);
return $row;
}
}