BlockCategoryListingForm.php in Layout Builder Browser 8
File
src/Form/BlockCategoryListingForm.php
View source
<?php
namespace Drupal\layout_builder_browser\Form;
use Drupal\Component\Utility\Html;
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
class BlockCategoryListingForm extends DraggableListBuilder {
public function getFormId() {
return "layout_builder_browser_block_category_listing";
}
public function buildHeader() {
$header['label'] = $this
->t('Name');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = Html::escape($entity
->label());
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['title'] = $this
->t('Edit');
}
return $operations;
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$form['actions']['submit']['#value'] = $this
->t('Save');
return $form;
}
}