sirv-8.x-3.0-beta4/sirv.module
sirv.module
<?php
/**
* @file
* Hook implementations and global functions for Sirv module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\sirv\SirvPreprocess;
/**
* Implements hook_help().
*/
function sirv_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the sirv module.
case 'help.page.sirv':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t("Provides integration with Sirv's image processing and hosting platform.") . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme_registry_alter().
*/
function sirv_theme_registry_alter(&$theme_registry) {
// Alter the image_formatter theme template to support storing Sirv data.
if (isset($theme_registry['image_formatter'])) {
$theme_registry['image_formatter']['variables']['sirv'] = [];
}
// Alter the image_style theme template to support storing Sirv data.
if (isset($theme_registry['image_style'])) {
$theme_registry['image_style']['variables']['sirv'] = [];
}
// Alter the image theme template to support storing Sirv data.
if (isset($theme_registry['image'])) {
$theme_registry['image']['variables']['sirv'] = [];
}
}
/**
* Implements hook_preprocess_HOOK() for image_formatter.
*/
function sirv_preprocess_image_formatter(&$variables) {
\Drupal::classResolver()->getInstanceFromDefinition(SirvPreprocess::class)->preprocessImageFormatter($variables);
}
/**
* Implements hook_preprocess_HOOK() for image_style.
*/
function sirv_preprocess_image_style(&$variables) {
\Drupal::classResolver()->getInstanceFromDefinition(SirvPreprocess::class)->preprocessImageStyle($variables);
}
/**
* Implements hook_preprocess_HOOK() for image.
*/
function sirv_preprocess_image(&$variables) {
\Drupal::classResolver()->getInstanceFromDefinition(SirvPreprocess::class)->preprocessImage($variables);
}
