You are here

function amp_entity_view_mode_alter in Accelerated Mobile Pages (AMP) 8.2

Same name and namespace in other branches
  1. 8.3 amp.module \amp_entity_view_mode_alter()
  2. 8 amp.module \amp_entity_view_mode_alter()
  3. 7 amp.module \amp_entity_view_mode_alter()

Implements hook_entity_view_mode_alter().

File

./amp.module, line 32

Code

function amp_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) {
  $amp_context = \Drupal::service('router.amp_context');

  // If on AMP route, and in full view mode, switch to AMP view mode.
  if ($amp_context
    ->isAmpRoute(NULL, $entity) && $view_mode == 'full') {
    $view_mode = 'amp';
  }
}