How do i change the visibility of an existing block programmatically? How do i change the visibility of an existing block programmatically?

I created the block using yml, here's the configuration: 

uuid: 67105709-2648-445e-9ddd-8b830a854d8d
langcode: en
status: true
dependencies:
  module:
    - pixelpin_openid_connect
    - system
  theme:
    - bartik
id: openidconnectlogin
theme: bartik
region: content
weight: 0
provider: null
plugin: pixelpin_openid_connect_login
settings:
  id: pixelpin_openid_connect_login
  label: 'PixelPin OpenID Connect Login'
  provider: pixelpin_openid_connect
  label_display: visible
visibility:
  request_path:
    id: request_path
    pages: /user/login
    negate: false
    context_mapping: {  }


The block visibility will change depending on whether a checkbox is checked so i cannot modify the existing block using yml (if that's even possible) unless you can call it in code.
You can load the block and modify the visibility settings:

$block = \Drupal\block\Entity\Block::load('openidconnectlogin');
$visibility = $block-&gt;getVisibility();
if (isset($visibility['request_path']['pages'])) {
  $visibility['request_path']['pages'] = '/new/path';
  $block-&gt;setVisibilityConfig('request_path', $visibility['request_path']);
  $block-&gt;save();
}