Retrieve unique block ID or machine name in build() method of BlockBase class

Created on 26 July 2015, almost 9 years ago
Updated 15 November 2023, 8 months ago

Is it possible to retrieve the unique block id or the machine name in the build() method of a block? When creating multiple instances of the same block definition, I can't manage to get a unique value per block from within the block methods (like for example the ID that gets appended to the machine name, or the machine name itself). I tried out all methods and properties of the BlockBase class, but no results.

Thanks in advance for any help on this.

πŸ’¬ Support request
Status

Active

Version

11.0 πŸ”₯

Component
BlockΒ  β†’

Last updated 2 days ago

Created by

πŸ‡§πŸ‡ͺBelgium Fernly

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States devkinetic

    Moving this up to the next major version, in the meantime, the workaround in #10 does the trick. I will note that blocks need to be resaved before the new info is stored in the the configuration.

  • πŸ‡¨πŸ‡¦Canada _randy

    #10 seems to only work for non-Layout Builder instances. Otherwise the callback_object in layout builder does not have a getEntity() method and fails.

Production build 0.69.0 2024