You are here

public function LayoutBuilderIdsConfigureSection::LayoutBuilderIdsSubmitForm in Layout builder ids 8

File

src/EventSubscriber/LayoutBuilderIdsConfigureSection.php, line 52

Class

LayoutBuilderIdsConfigureSection
Class LayoutBuilderIdsConfigureSection.

Namespace

Drupal\layout_builder_ids\EventSubscriber

Code

public function LayoutBuilderIdsSubmitForm(array &$form, FormStateInterface $form_state) {

  // Get the layout builder id from the form.
  $layout_builder_id = $form_state
    ->getValue([
    'layout_settings',
    'layout_builder_id',
  ], NULL);

  // If there is a layout builder id, store it.
  if ($layout_builder_id !== NULL) {

    // Get the layout.
    $layout = $this
      ->getLayout($form_state);

    // Load in the config for this section.
    $configuration = $layout
      ->getConfiguration();

    // Set the layout builder id in config variable.
    $configuration['layout_builder_id'] = Html::getId($layout_builder_id);

    // Set the config for this section.
    $layout
      ->setConfiguration($configuration);
  }
}