You are here

BrowserListBuilder.php in Paragraphs Browser 8

File

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

namespace Drupal\paragraphs_browser\Controller;

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

/**
 * Provides a listing of BrowserType.
 */
class BrowserListBuilder extends ConfigEntityListBuilder {

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

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $row['label'] = $entity
      ->label();
    $row['id'] = $entity
      ->id();

    // You probably want a few more properties here...
    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;
    }
    $operations['groups'] = array(
      'title' => t('Manage Groups'),
      'weight' => -40,
      'url' => $entity
        ->toUrl('groups-form'),
    );
    return $operations;
  }

}

Classes

Namesort descending Description
BrowserListBuilder Provides a listing of BrowserType.