CustomBlockRenderController.php

Contains \Drupal\custom_block\CustomBlockRenderController.

Namespace

Drupal\custom_block

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php
View source
<?php

/**
 * @file
 * Contains \Drupal\custom_block\CustomBlockRenderController.
 */
namespace Drupal\custom_block;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRenderController;
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;

/**
 * Render controller for custom blocks.
 */
class CustomBlockRenderController extends EntityRenderController {

  /**
   * Overrides \Drupal\Core\Entity\EntityRenderController::alterBuild().
   */
  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
    parent::alterBuild($build, $entity, $display, $view_mode, $langcode);

    // Add contextual links for this custom block.
    if (!empty($entity->id->value) && $view_mode == 'full') {
      $build['#contextual_links']['custom_block'] = array(
        'block',
        array(
          $entity
            ->id(),
        ),
      );
    }
  }

}

Classes

Namesort descending Description
CustomBlockRenderController Render controller for custom blocks.