function ChooseBlockController::inlineBlockList

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Controller/ChooseBlockController.php \Drupal\layout_builder\Controller\ChooseBlockController::inlineBlockList()
  2. 8.9.x core/modules/layout_builder/src/Controller/ChooseBlockController.php \Drupal\layout_builder\Controller\ChooseBlockController::inlineBlockList()
  3. 10 core/modules/layout_builder/src/Controller/ChooseBlockController.php \Drupal\layout_builder\Controller\ChooseBlockController::inlineBlockList()

Provides the UI for choosing a new inline block.

Parameters

\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.

int $delta: The delta of the section to splice.

string $region: The region the block is going in.

Return value

array A render array.

1 string reference to 'ChooseBlockController::inlineBlockList'
layout_builder.routing.yml in core/modules/layout_builder/layout_builder.routing.yml
core/modules/layout_builder/layout_builder.routing.yml

File

core/modules/layout_builder/src/Controller/ChooseBlockController.php, line 175

Class

ChooseBlockController
Defines a controller to choose a new block.

Namespace

Drupal\layout_builder\Controller

Code

public function inlineBlockList(SectionStorageInterface $section_storage, int $delta, $region) {
    $definitions = $this->blockManager
        ->getFilteredDefinitions('layout_builder', $this->getPopulatedContexts($section_storage), [
        'section_storage' => $section_storage,
        'region' => $region,
        'list' => 'inline_blocks',
    ]);
    $blocks = $this->blockManager
        ->getGroupedDefinitions($definitions);
    $build = [];
    $inline_blocks_category = (string) $this->t('Inline blocks');
    if (isset($blocks[$inline_blocks_category])) {
        $build['links'] = $this->getBlockLinks($section_storage, $delta, $region, $blocks[$inline_blocks_category]);
        $build['links']['#attributes']['class'][] = 'inline-block-list';
        foreach ($build['links']['#links'] as &$link) {
            $link['attributes']['class'][] = 'inline-block-list__item';
        }
        $build['back_button'] = [
            '#type' => 'link',
            '#url' => Url::fromRoute('layout_builder.choose_block', [
                'section_storage_type' => $section_storage->getStorageType(),
                'section_storage' => $section_storage->getStorageId(),
                'delta' => $delta,
                'region' => $region,
            ]),
            '#title' => $this->t('Back'),
            '#attributes' => $this->getAjaxAttributes(),
        ];
    }
    $build['links']['#attributes']['data-layout-builder-target-highlight-id'] = $this->blockAddHighlightId($delta, $region);
    return $build;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.