how to know block id in class which extend from BlockBase I am trying to get block id in my custom module  in build function of class which extends BlockBase.

How can i do this?

i want to use this block_id in another class controller to have configuration of that block so i think best place to get block id and send it to controller class is build function like below code

        class XController extends ControllerBase{
        ...
        $block = \Drupal\block\Entity\Block::load($block_id);
        if ($block) {
        ...


any other suggestion to do this is appreciated.
BlockBase is a plugin, and as such has a getPluginId method. As you need this inside the class itself, it's as easy as:

$id = $this-&gt;getPluginId();