You are here

TemplateListBuilder.php in Wysiwyg API template plugin 8.2

Same filename and directory in other branches
  1. 3.0.x src/TemplateListBuilder.php

File

src/TemplateListBuilder.php
View source
<?php

namespace Drupal\wysiwyg_template;

use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a listing of Template entities.
 */
class TemplateListBuilder extends DraggableListBuilder {

  /**
   * {@inheritdoc}
   */
  public function getFormId() : string {
    return 'wysiwyg_template_list_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildHeader() : array {
    $header['label'] = $this
      ->t('Template');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) : array {
    $row['label'] = $entity
      ->label();
    return $row + parent::buildRow($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) : array {
    $form = parent::buildForm($form, $form_state);

    // Better empty text.
    $form[$this->entitiesKey]['#empty'] = $this
      ->t('There are no WYSIWYG templates yet.');
    return $form;
  }

}

Classes

Namesort descending Description
TemplateListBuilder Provides a listing of Template entities.