function view_mode_page_block_build_alter in View Mode Page 8.3
Same name and namespace in other branches
- 4.0.x view_mode_page.module \view_mode_page_block_build_alter()
- 3.2.x view_mode_page.module \view_mode_page_block_build_alter()
Implements hook_block_build_alter().
Adds additional cache_contexts to the system_main_block, to prevent incorrect caching of a single view_mode (when using a path alias).
Parameters
array $build:
\Drupal\Core\Block\BlockPluginInterface $block:
File
- ./
view_mode_page.module, line 39 - Contains view_mode_page module.
Code
function view_mode_page_block_build_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
if ($block
->getBaseId() == 'system_main_block') {
$build['#cache']['contexts'][] = 'url.path';
}
}