set('visibility', [ 'user_role' => [ 'id' => 'user_role', 'negate' => FALSE, 'context_mapping' => [ 'user' => '@user.current_user_context:current_user', ], 'roles' => ['anonymous' => 'anonymous'], ], ]); $block->save(); echo "metro_user_login restricted to anonymous" . PHP_EOL;