You are here

function panopoly_widgets_entity_view_alter in Panopoly Widgets 8.2

Implements hook_entity_view_alter().

File

./panopoly_widgets.module, line 22
Hooks for Panopoly Widgets module.

Code

function panopoly_widgets_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  if ($entity
    ->getEntityTypeId() === 'block_content' && $entity
    ->bundle() === PANOPOLY_WIDGETS_IMAGE_BUNDLE) {
    $link_uri = $entity->field_panopoly_widgets_link->uri;
    if (!empty($link_uri)) {
      $url = Url::fromUri($link_uri);
      $build["field_panopoly_widgets_image"][0]["#url"] = $url;
    }
  }
}