private function BlockListingForm::buildBlockRow in Layout Builder Browser 8
Builds one block row.
The block.
Return value
array Row with information about block.
1 call to BlockListingForm::buildBlockRow()
- BlockListingForm::buildForm in src/
Form/ BlockListingForm.php - Form constructor.
File
- src/
Form/ BlockListingForm.php, line 148
Class
- BlockListingForm
- Builds a listing of block entities.
Namespace
Drupal\layout_builder_browser\FormCode
private function buildBlockRow($block) {
$row = [];
$row['title'] = [
'#type' => 'markup',
'#markup' => '<div class="block-title">' . $block['label'] . '</div>',
];
$row['block_provider'] = [
'#type' => 'markup',
'#markup' => $block["block_provider"],
];
$block_categories = $this->entityTypeManager
->getStorage('layout_builder_browser_blockcat')
->loadMultiple();
uasort($block_categories, [
'Drupal\\Core\\Config\\Entity\\ConfigEntityBase',
'sort',
]);
$categories_options = [];
foreach ($block_categories as $block_category) {
$categories_options[$block_category
->id()] = $block_category
->label();
}
$row['category'] = [
'#type' => 'select',
'#options' => $categories_options,
'#default_value' => $block['category'],
'#attributes' => [
'class' => [
'block-region-select',
'block-region-' . $block['category'],
],
],
];
$row['#attributes'] = [
'title' => $this
->t('ID: @name', [
'@name' => $block['id'],
]),
'class' => [
'block-wrapper',
'draggable',
],
];
$row['weight'] = [
'#type' => 'weight',
'#default_value' => $block['weight'],
'#delta' => 100,
'#title' => $this
->t('Weight for @block block', [
'@block' => $block['label'],
]),
'#title_display' => 'invisible',
'#attributes' => [
'class' => [
'block-weight',
'block-weight-' . $block['category'],
],
],
];
$row['operations'] = [
'#type' => 'link',
'#title' => $this
->t('edit'),
'#url' => Url::fromRoute('entity.layout_builder_browser_block.edit_form', [
'layout_builder_browser_block' => $block['id'],
]),
'#attributes' => [
'class' => [
'use-ajax',
'button',
'button--small',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 700,
]),
],
];
return $row;
}