You are here

public function CheeseburgerMenuService::buildRegionRow in Cheeseburger Menu 5.0.x

Builds region row.

Parameters

string|\Drupal\Core\StringTranslation\TranslatableMarkup $title: Region title.

string $region_name: Region machine name.

Return value

array Region row.

1 call to CheeseburgerMenuService::buildRegionRow()
CheeseburgerMenuService::getMenusAsRows in src/CheeseburgerMenuService.php
Returns sortable menu rows for cheeseburger config form.

File

src/CheeseburgerMenuService.php, line 257

Class

CheeseburgerMenuService
Base service providing functions.

Namespace

Drupal\cheeseburger_menu

Code

public function buildRegionRow($title, $region_name) {
  $color = $region_name === 'enabled' ? 'ccfcca' : 'f0a19c';
  $row = [
    '#attributes' => [
      'style' => "background-color: #{$color}",
    ],
  ];
  $row['label'] = [
    '#markup' => '<b>' . $title . '</b>',
  ];
  $row['weight'] = [
    '#type' => 'hidden',
    '#attributes' => [
      'class' => [
        'weight',
      ],
    ],
  ];
  $row['menu_type'] = [
    '#type' => 'hidden',
    '#value' => $region_name,
    '#wrapper_attributes' => [
      'colspan' => 2,
    ],
  ];
  $row['#menu_id'] = $region_name;
  return $row;
}