You are here

public function DynamicLayout::setCustomColumnWidthNumber in Dynamic Layouts 8

Set the custom column width number.

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.

string $column_width_number: The column width number.

Overrides DynamicLayoutInterface::setCustomColumnWidthNumber

File

src/Entity/DynamicLayout.php, line 257

Class

DynamicLayout
Defines the DynamicLayout entity.

Namespace

Drupal\dynamic_layouts\Entity

Code

public function setCustomColumnWidthNumber($row_id, $column_id, $custom_column_width_number) {
  $updated_row = $this
    ->getRowById($row_id);
  $updated_column = $this
    ->getColumnById($updated_row, $column_id);
  $updated_column[Constants::CUSTOM_COLUMN_WIDTH_NUMBER] = $custom_column_width_number;
  $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);
}