BlockContentTypeListBuilder.php

Same filename in other branches
  1. 8.9.x core/modules/block_content/src/BlockContentTypeListBuilder.php
  2. 10 core/modules/block_content/src/BlockContentTypeListBuilder.php
  3. 11.x core/modules/block_content/src/BlockContentTypeListBuilder.php

Namespace

Drupal\block_content

File

core/modules/block_content/src/BlockContentTypeListBuilder.php

View source
<?php

namespace Drupal\block_content;

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

/**
 * Defines a class to build a listing of custom block type entities.
 *
 * @see \Drupal\block_content\Entity\BlockContentType
 */
class BlockContentTypeListBuilder extends ConfigEntityListBuilder {
    
    /**
     * {@inheritdoc}
     */
    public function getDefaultOperations(EntityInterface $entity) {
        $operations = parent::getDefaultOperations($entity);
        // Place the edit operation after the operations added by field_ui.module
        // which have the weights 15, 20, 25.
        if (isset($operations['edit'])) {
            $operations['edit']['weight'] = 30;
        }
        return $operations;
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildHeader() {
        $header['type'] = $this->t('Block type');
        $header['description'] = $this->t('Description');
        return $header + parent::buildHeader();
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildRow(EntityInterface $entity) {
        $row['type'] = $entity->toLink(NULL, 'edit-form')
            ->toString();
        $row['description']['data']['#markup'] = $entity->getDescription();
        return $row + parent::buildRow($entity);
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getTitle() {
        return $this->t('Custom block types');
    }

}

Classes

Title Deprecated Summary
BlockContentTypeListBuilder Defines a class to build a listing of custom block type entities.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.