Implements hook_preprocess_HOOK() for block.html.twig.
function system_preprocess_block(&$variables) {
// Derive the base plugin ID.
list($plugin_id) = explode(':', $variables['plugin_id'] . ':');
switch ($plugin_id) {
case 'system_powered_by_block':
$variables['attributes']['role'] = 'complementary';
break;
case 'system_help_block':
$variables['attributes']['role'] = 'complementary';
break;
case 'system_menu_block':
$variables['attributes']['role'] = 'navigation';
$variables['attributes']['class'][] = 'block-menu';
}
}