3 namespace Drupal\config_translation\Controller;
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\EntityStorageInterface;
7 use Drupal\Core\Entity\EntityTypeInterface;
8 use Drupal\Core\Extension\ThemeHandlerInterface;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
12 * Defines the config translation list builder for blocks.
14 class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuilder {
17 * An array of theme info keyed by theme name.
21 protected $themes = [];
26 public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, ThemeHandlerInterface $theme_handler) {
27 parent::__construct($entity_type, $storage);
28 $this->themes = $theme_handler->listInfo();
34 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
37 $container->get('entity.manager')->getStorage($entity_type->id()),
38 $container->get('theme_handler')
45 public function getFilterLabels() {
46 $info = parent::getFilterLabels();
48 $info['placeholder'] = $this->t('Enter block, theme or category');
49 $info['description'] = $this->t('Enter a part of the block, theme or category to filter by.');
57 public function buildRow(EntityInterface $entity) {
58 $theme = $entity->getTheme();
59 $plugin_definition = $entity->getPlugin()->getPluginDefinition();
62 'data' => $entity->label(),
63 'class' => 'table-filter-text-source',
67 'data' => $this->themes[$theme]->info['name'],
68 'class' => 'table-filter-text-source',
72 'data' => $plugin_definition['category'],
73 'class' => 'table-filter-text-source',
76 $row['operations']['data'] = $this->buildOperations($entity);
84 public function buildHeader() {
85 $header['label'] = $this->t('Block');
86 $header['theme'] = $this->t('Theme');
87 $header['category'] = $this->t('Category');
88 $header['operations'] = $this->t('Operations');
95 public function sortRows($a, $b) {
96 return $this->sortRowsMultiple($a, $b, ['theme', 'category', 'label']);