CMS Drupal Mastering Development

Placing a programatically created menu

I’m creating a menu programatically using this code

$this->menu = $this->entityTypeManager->getStorage('menu')->create(
      'id' => $properties['id'],
      'label' => $properties['label'],
      'langcode' => $properties['language'],
      'status' => TRUE,
  // Save the menu.

When visiting the block ui I see the block is already created. It appears that I do not have responsibility for creating this block, although I don’t seem to be able to load the block straight after creation of the menu. I need to place this block in a specific region programatically. What would be the preferred method of doing this be?

Leave a Reply

Your email address will not be published. Required fields are marked *