You are here

public function ContainerForm::save in GoogleTagManager 8

Form submission handler for the 'save' action.

Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Overrides EntityForm::save

File

src/Form/ContainerForm.php, line 293

Class

ContainerForm
Defines the Google tag manager container settings form.

Namespace

Drupal\google_tag\Form

Code

public function save(array $form, FormStateInterface $form_state) {

  // Drupal/Core/Condition/ConditionPluginCollection.php
  // On save, above class filters any condition with default configuration.
  // See ::getConfiguration()
  // The database row omits such conditions from the container 'conditions'.
  // google_tag/src/ContainerAccessControlHandler.php
  // On access check, the list of conditions only includes those in database.
  // Those with default configuration are assumed not to apply as the default
  // values should produce no restriction.
  // However, core treats an empty values list opposite this module.
  parent::save($form, $form_state);

  // @todo This could be done in container::postSave() method.
  global $_google_tag_display_message;
  $_google_tag_display_message = TRUE;
  $manager = \Drupal::service('google_tag.container_manager');
  $manager
    ->createAssets($this->entity);

  // Redirect to collection page.
  $form_state
    ->setRedirect('entity.google_tag_container.collection');
}