You are here

public function SettingsForm::updateValues in Dynamic Layouts 8

Update the setting values.

Parameters

string $new_column_prefix: The new column prefix.

int $new_grid_column_count: The new grid column count.

int $last_column_number: The last column number.

object $old_frontend_library: The old frontend library.

object $new_frontend_library: The new frontend library.

\Drupal\dynamic_layouts\DynamicLayoutSettingsInterface $settings: The settings object.

1 call to SettingsForm::updateValues()
SettingsForm::submitForm in src/Form/SettingsForm.php
Form submission handler.

File

src/Form/SettingsForm.php, line 198

Class

SettingsForm
Provides a generic settings form for the DynamicLayouts.

Namespace

Drupal\dynamic_layouts\Form

Code

public function updateValues($new_column_prefix, $new_grid_column_count, $last_column_number, $old_frontend_library, $new_frontend_library, DynamicLayoutSettingsInterface $settings) {

  // Column prefix changed?
  if ($new_column_prefix) {
    $old_column_prefix = $settings
      ->getColumnPrefix();
    if ($old_column_prefix != $new_column_prefix) {
      $settings
        ->purgeColumnWidthNumbers($last_column_number, $new_column_prefix);
    }
    $settings
      ->setColumnPrefix($new_column_prefix);
  }

  // Grid column count changed?
  if ($new_grid_column_count) {
    $old_grid_column_count = $settings
      ->getGridColumnCount();
    if ($old_grid_column_count != $new_grid_column_count) {
      $settings
        ->purgeColumnWidthNumbers($last_column_number);
    }
    $settings
      ->setGridColumnCount($new_grid_column_count);
  }

  // Frontend library changed?
  if ($old_frontend_library != $new_frontend_library) {
    $settings
      ->purgeColumnWidthNumbers($last_column_number, $new_column_prefix);
    if ($old_frontend_library) {
      $this
        ->messenger()
        ->addError($this
        ->t('All column widths have been purged, please reconfigure your layouts!'));
    }
    $settings
      ->setFrontendLibrary($new_frontend_library);
  }
}