2 * Implements hook_block_build_alter().
4 function {{ machine_name }}_block_build_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
5 // Add the 'user' cache context to some blocks.
6 if ($block->label() === 'some condition') {
7 $build['#cache']['contexts'][] = 'user';