namespace Drupal\layout_builder\Controller;
+use Drupal\Core\Ajax\AjaxHelperTrait;
use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Drupal\layout_builder\Context\LayoutBuilderContextTrait;
use Drupal\layout_builder\SectionStorageInterface;
use AjaxHelperTrait;
use LayoutBuilderContextTrait;
+ use StringTranslationTrait;
/**
* The block manager.
* A render array.
*/
public function build(SectionStorageInterface $section_storage, $delta, $region) {
+ $build['#title'] = $this->t('Choose a block');
$build['#type'] = 'container';
$build['#attributes']['class'][] = 'block-categories';
- $definitions = $this->blockManager->getDefinitionsForContexts($this->getAvailableContexts($section_storage));
+ // @todo Explicitly cast delta to an integer, remove this in
+ // https://www.drupal.org/project/drupal/issues/2984509.
+ $delta = (int) $delta;
+
+ $definitions = $this->blockManager->getFilteredDefinitions('layout_builder', $this->getAvailableContexts($section_storage), [
+ 'section_storage' => $section_storage,
+ 'delta' => $delta,
+ 'region' => $region,
+ ]);
foreach ($this->blockManager->getGroupedDefinitions($definitions) as $category => $blocks) {
$build[$category]['#type'] = 'details';
$build[$category]['#open'] = TRUE;