Check access to existing plugin block I have a programmatical plugin block defined in theme region. I need to check access to this block in my module hook. The following code creates a new instance, but I need to load an existing plugin block from the theme with its custom visibility settings and find out if it is going to be displayed or not.

$block_manager = \Drupal::service('plugin.manager.block');
$config = [];
$plugin_block = $block_manager-&gt;createInstance('system_breadcrumb_block', $config);
$access_result = $plugin_block-&gt;access(\Drupal::currentUser());


Please advise.
Loading a block should be in theme context, because block visibility configured by theme, here is an example to how load system_breadcrumb_block block in your active theme.

   use Drupal\block\Entity\Block;  
    // Get block ids.
        // This will return block ids by theme like the following
        /*  [
              "bartik_breadcrumbs" =&gt; "bartik_breadcrumbs"
              "seven_breadcrumbs" =&gt; "seven_breadcrumbs"
            ]
        */
        $ids = \Drupal::entityQuery('block')
          -&gt;condition('plugin', 'system_breadcrumb_block')
          -&gt;execute();
        // Get the active theme name.
        $active_theme_name = \Drupal::service('theme.manager')
          -&gt;getActiveTheme()
          -&gt;getName();
        $my_block_id = '';
        foreach ($ids as $id) {
          // Check the if the id start with theme name.
          if (strpos($id, $active_theme_name) === 0) {
            $my_block_id = $id;
          }
        }
        // Load Block.
        $block = Block::load($my_block_id);
        // Get the block visibility array
        // Something like
        //    [
        //      "user_role" =&gt; [
        //        "id"    =&gt; "user_role",
        //        "roles" =&gt; [
        //          "administrator" =&gt; "administrator",
        //        ],
        //      ],
        //    ]
        $visibility = $block-&gt;getVisibility();
        $currentUser = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id());
        /**
         * TODO: Do your visibility check
         */
        // Example to check if the user has the access by role
        $has_access = FALSE;
        if ($visibility['user_role']['roles']){
          foreach ($visibility['user_role']['roles'] as $role =&gt; $name){
            if ($currentUser-&gt;hasRole($role)){
              $has_access = TRUE;
            }
          }
        }
        dpm($has_access);