You are here

public function AutoEntityLabelForm::submitForm in Automatic Entity Label 8.2

Same name and namespace in other branches
  1. 8.3 src/Form/AutoEntityLabelForm.php \Drupal\auto_entitylabel\Form\AutoEntityLabelForm::submitForm()
  2. 8 src/Form/AutoEntityLabelForm.php \Drupal\auto_entitylabel\Form\AutoEntityLabelForm::submitForm()

Form submission handler.

Parameters

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

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

Overrides ConfigFormBase::submitForm

File

src/Form/AutoEntityLabelForm.php, line 267

Class

AutoEntityLabelForm
Class AutoEntityLabelForm.

Namespace

Drupal\auto_entitylabel\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->getEditable($this
    ->getConfigName());
  $form_state
    ->cleanValues();
  foreach ([
    'status',
    'pattern',
    'php',
    'escape',
  ] as $key) {
    $config
      ->set($key, $form_state
      ->getValue($key));
  }

  /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
  $storage = $this->entityManager
    ->getStorage($this->entityType);

  /** @var \Drupal\Core\Config\Entity\ConfigEntityType $entity_type */
  $entity_type = $storage
    ->getEntityType();
  $prefix = $entity_type
    ->getConfigPrefix();
  $config
    ->set('dependencies', [
    'config' => [
      $prefix . '.' . $this->entityBundle,
    ],
  ]);
  $config
    ->save();
  parent::submitForm($form, $form_state);
}