BlockContentViewBuilder.php in Zircon Profile 8
File
core/modules/block_content/src/BlockContentViewBuilder.php
View source
<?php
namespace Drupal\block_content;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityViewBuilder;
class BlockContentViewBuilder extends EntityViewBuilder {
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
return $this
->viewMultiple(array(
$entity,
), $view_mode, $langcode)[0];
}
public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
$build_list = parent::viewMultiple($entities, $view_mode, $langcode);
unset($build_list['#pre_render'][0]);
return $this
->buildMultiple($build_list);
}
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
unset($build['#theme']);
return $build;
}
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $entity, $display, $view_mode);
if (!$entity
->isNew()) {
$build['#contextual_links']['block_content'] = array(
'route_parameters' => array(
'block_content' => $entity
->id(),
),
'metadata' => array(
'changed' => $entity
->getChangedTime(),
),
);
}
}
}