You are here

ContributorRoleListBuilder.php in Bibliography & Citation 2.0.x

Same filename and directory in other branches
  1. 8 modules/bibcite_entity/src/ContributorRoleListBuilder.php

File

modules/bibcite_entity/src/ContributorRoleListBuilder.php
View source
<?php

namespace Drupal\bibcite_entity;

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

/**
 * Provides a listing of Contributor role entities.
 */
class ContributorRoleListBuilder extends DraggableListBuilder {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'bibcite_contributor_role_overview';
  }

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

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

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    $form['role_list_description'] = [
      '#type' => 'label',
      '#title' => $this
        ->t('First value in the list is used as default contributor role.'),
    ];
    return $form;
  }

}

Classes

Namesort descending Description
ContributorRoleListBuilder Provides a listing of Contributor role entities.