You are here

public function DynamicLayout::setCustomColumnClasses in Dynamic Layouts 8

Set the layout column classes.

Parameters

int $row_id: The row number we need to set the classes on.

int $column_id: The column id we need to set the classes on.

array $column_classes: The column classes.

Overrides DynamicLayoutInterface::setCustomColumnClasses

File

src/Entity/DynamicLayout.php, line 189

Class

DynamicLayout
Defines the DynamicLayout entity.

Namespace

Drupal\dynamic_layouts\Entity

Code

public function setCustomColumnClasses($row_id, $column_id, array $column_classes) {
  $updated_row = $this
    ->getRowById($row_id);
  $updated_column = $this
    ->getColumnById($updated_row, $column_id);
  $updated_column[Constants::CUSTOM_COLUMN_CLASSES] = $column_classes;
  $columns = $updated_row[Constants::COLUMNS];

  // Loop over the columns and set the updated column.
  foreach ($columns as $key => $column) {
    if ($column[Constants::COLUMN_ID] == $column_id) {
      $columns[$key] = $updated_column;
    }
  }

  // Loop over the rows and find the corresponding row number.
  $rows = $this
    ->getRows();
  foreach ($rows as $key => $row) {
    if ($row[Constants::ROW_ID] == $row_id) {
      $rows[$key][Constants::COLUMNS] = $columns;
    }
  }
  $this->regions = serialize($rows);
}