|
|
@ -257,7 +257,9 @@ function islandora_entity_view_mode_alter(&$view_mode, EntityInterface $entity) |
|
|
|
// ContextReaction. |
|
|
|
// ContextReaction. |
|
|
|
$storage = \Drupal::service('entity_type.manager')->getStorage('entity_view_mode'); |
|
|
|
$storage = \Drupal::service('entity_type.manager')->getStorage('entity_view_mode'); |
|
|
|
$context_manager = \Drupal::service('context.manager'); |
|
|
|
$context_manager = \Drupal::service('context.manager'); |
|
|
|
|
|
|
|
$current_entity = \Drupal::routeMatch()->getParameter('node'); |
|
|
|
|
|
|
|
$current_id = ($current_entity instanceof NodeInterface) ? $current_entity->id() : NULL; |
|
|
|
|
|
|
|
if (isset($current_id) && $current_id == $entity->id()) { |
|
|
|
foreach ($context_manager->getActiveReactions('\Drupal\islandora\Plugin\ContextReaction\ViewModeAlterReaction') as $reaction) { |
|
|
|
foreach ($context_manager->getActiveReactions('\Drupal\islandora\Plugin\ContextReaction\ViewModeAlterReaction') as $reaction) { |
|
|
|
// Construct the new view mode's machine name. |
|
|
|
// Construct the new view mode's machine name. |
|
|
|
$entity_type = $entity->getEntityTypeId(); |
|
|
|
$entity_type = $entity->getEntityTypeId(); |
|
|
@ -273,7 +275,9 @@ function islandora_entity_view_mode_alter(&$view_mode, EntityInterface $entity) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// Otherwise, leave it be, but log a message. |
|
|
|
// Otherwise, leave it be, but log a message. |
|
|
|
\Drupal::logger('islandora')->info("EntityViewMode $machine_name does not exist. View mode cannot be altered."); |
|
|
|
\Drupal::logger('islandora') |
|
|
|
|
|
|
|
->info("EntityViewMode $machine_name does not exist. View mode cannot be altered."); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|