Where should I place hook_block_view_alter?
In drupal 8 the declaration of hook_block_view_alter changed from hook_block_view_alter(&amp;$data, $block) (Drupal7) to  hook_block_view_alter(array &amp;$build, \Drupal\Core\Block\BlockPluginInterface $block) (Drupal 8).
For more info check hook_block_view_alter Documentation page.

hook_block_view_alter be better in custom module not theme, see guide to building basic Drupal 8 module, and flush all caches.