You are here

private function BlockListingForm::buildBlockCategoryRow in Layout Builder Browser 8

Builds an array of block categorie for display in the overview.

1 call to BlockListingForm::buildBlockCategoryRow()
BlockListingForm::buildForm in src/Form/BlockListingForm.php
Form constructor.

File

src/Form/BlockListingForm.php, line 223

Class

BlockListingForm
Builds a listing of block entities.

Namespace

Drupal\layout_builder_browser\Form

Code

private function buildBlockCategoryRow($block_category) {
  return [
    'title' => [
      '#theme_wrappers' => [
        'container' => [
          '#attributes' => [
            'class' => [
              'block-category-title',
              'region-title__action',
            ],
          ],
        ],
      ],
      '#type' => 'link',
      '#prefix' => Html::escape($block_category
        ->label()),
      '#title' => $this
        ->t('Place block <span class="visually-hidden">in %category</span>', [
        '%category' => Html::escape($block_category
          ->label()),
      ]),
      '#url' => Url::fromRoute('entity.layout_builder_browser_block.add_form', [], [
        'query' => [
          'blockcat' => $block_category
            ->id(),
        ],
      ]),
      '#attributes' => [
        'class' => [
          'use-ajax',
          'button',
          'button--small',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => 700,
        ]),
      ],
      '#wrapper_attributes' => [
        'colspan' => 5,
      ],
    ],
    '#attributes' => [
      'class' => [
        'region-title',
        'region-title-' . $block_category
          ->id(),
      ],
    ],
  ];
}