3 namespace Drupal\block_content;
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Entity\EntityViewBuilder;
9 * View builder handler for custom blocks.
11 class BlockContentViewBuilder extends EntityViewBuilder {
16 public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
17 return $this->viewMultiple([$entity], $view_mode, $langcode)[0];
23 public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) {
24 $build_list = parent::viewMultiple($entities, $view_mode, $langcode);
25 // Apply the buildMultiple() #pre_render callback immediately, to make
26 // bubbling of attributes and contextual links to the actual block work.
27 // @see \Drupal\block\BlockViewBuilder::buildBlock()
28 unset($build_list['#pre_render'][0]);
29 return $this->buildMultiple($build_list);
35 protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
36 $build = parent::getBuildDefaults($entity, $view_mode);
37 // The custom block will be rendered in the wrapped block template already
38 // and thus has no entity template itself.
39 unset($build['#theme']);