You are here

panopoly_widgets.module in Panopoly Widgets 8.2

Same filename and directory in other branches
  1. 7 panopoly_widgets.module

Hooks for Panopoly Widgets module.

File

panopoly_widgets.module
View source
<?php

/**
 * @file
 * Hooks for Panopoly Widgets module.
 */
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;

/**
 * The default list of allowed file extensions in file widgets.
 */
define('PANOPOLY_WIDGETS_FILE_EXTENSIONS_DEFAULT', 'txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp');
define('PANOPOLY_WIDGETS_IMAGE_BUNDLE', 'panopoly_widgets_image');

/**
 * Implements hook_entity_view_alter().
 */
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;
    }
  }
}

Functions

Constants

Namesort descending Description
PANOPOLY_WIDGETS_FILE_EXTENSIONS_DEFAULT The default list of allowed file extensions in file widgets.
PANOPOLY_WIDGETS_IMAGE_BUNDLE