You are here

public function DynamicLayout::getIconMap in Dynamic Layouts 8

Get the icon map for this layout.

Overrides DynamicLayoutInterface::getIconMap

File

src/Entity/DynamicLayout.php, line 792

Class

DynamicLayout
Defines the DynamicLayout entity.

Namespace

Drupal\dynamic_layouts\Entity

Code

public function getIconMap() {
  $icon_map = [];
  $rows = $this
    ->getRows();
  foreach ($rows as $key => $row) {
    $icon_map[$key] = [];
    if (isset($row[Constants::COLUMNS]) && !empty(Constants::COLUMNS)) {
      $columns = $row[Constants::COLUMNS];
      foreach ($columns as $column) {
        $column_width_number = $column[Constants::COLUMN_WIDTH_NUMBER];
        if (isset($column[Constants::CUSTOM_COLUMN_WIDTH_NUMBER]) && !empty($column[Constants::CUSTOM_COLUMN_WIDTH_NUMBER])) {
          $column_width_number = $column[Constants::CUSTOM_COLUMN_WIDTH_NUMBER];
        }
        for ($i = 1; $i <= $column_width_number; $i++) {
          $icon_map[$key][] = $column[Constants::COLUMN_ID];
        }
      }
    }
  }
  return array_values($icon_map);
}