You are here

public function CourierTemplateCollection::submitConfigurationForm in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Action/CourierTemplateCollection.php \Drupal\rng\Plugin\Action\CourierTemplateCollection::submitConfigurationForm()
  2. 8 src/Plugin/Action/CourierTemplateCollection.php \Drupal\rng\Plugin\Action\CourierTemplateCollection::submitConfigurationForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides PluginFormInterface::submitConfigurationForm

File

src/Plugin/Action/CourierTemplateCollection.php, line 112

Class

CourierTemplateCollection
Creates a template collection and provides a user interface to its templates.

Namespace

Drupal\rng\Plugin\Action

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $configuration = $this
    ->getConfiguration();

  // Create new.
  if (!isset($configuration['template_collection'])) {
    $template_collection = TemplateCollection::create();
    if ($template_collection
      ->save()) {
      $this->courierManager
        ->addTemplates($template_collection);
      $template_collection
        ->save();
    }
    $this->configuration['template_collection'] = $template_collection
      ->id();
  }
}