You are here

ParagraphsSetListBuilder.php in Paragraphs Sets 8

Same filename and directory in other branches
  1. 8.2 src/Controller/ParagraphsSetListBuilder.php

File

src/Controller/ParagraphsSetListBuilder.php
View source
<?php

namespace Drupal\paragraphs_sets\Controller;

use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;

/**
 * Provides a listing of ParagraphsSet.
 */
class ParagraphsSetListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['label'] = $this
      ->t('Label');
    $header['id'] = $this
      ->t('Machine name');
    $header['description'] = $this
      ->t('Description');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity
      ->label();
    $row['id'] = $entity
      ->id();
    $row['description']['data'] = [
      '#markup' => $entity
        ->getDescription(),
    ];
    return $row + parent::buildRow($entity);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefaultOperations(EntityInterface $entity) {

    /** @var \Drupal\field\FieldConfigInterface $entity */
    $operations = parent::getDefaultOperations($entity);
    if (isset($operations['edit'])) {
      $operations['edit']['weight'] = 30;
    }
    return $operations;
  }

}

Classes

Namesort descending Description
ParagraphsSetListBuilder Provides a listing of ParagraphsSet.