$definitions =
$this->blockManager->
getFilteredDefinitions('layout_builder',
$this->
getPopulatedContexts($section_storage),
[ 'section_storage' =>
$section_storage,
'delta' =>
$delta,
'region' =>
$region,
]);
$grouped_definitions =
$this->blockManager->
getGroupedDefinitions($definitions);
foreach ($grouped_definitions as $category =>
$blocks) { $block_categories[$category]['#type'
] = 'details';
$block_categories[$category]['#attributes'
]['class'
][] = 'js-layout-builder-category';
$block_categories[$category]['#open'
] = TRUE;
$block_categories[$category]['#title'
] =
$category;
$block_categories[$category]['links'
] =
$this->
getBlockLinks($section_storage,
$delta,
$region,
$blocks);
} $build['block_categories'
] =
$block_categories;
return $build;
} /**
* Provides the UI for choosing a new inline block.
*
* @param \Drupal\layout_builder\SectionStorageInterface $section_storage
* The section storage.
* @param int $delta
* The delta of the section to splice.
* @param string $region
* The region the block is going in.
*
* @return array
* A render array.
*/