You are here

public function QueueStorageEntityTypeForm::save in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_queue_storage/src/Form/QueueStorageEntityTypeForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityTypeForm::save()
  2. 10.3.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityTypeForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityTypeForm::save()
  3. 10.0.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityTypeForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityTypeForm::save()
  4. 10.1.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityTypeForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityTypeForm::save()
  5. 10.2.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityTypeForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityTypeForm::save()

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

modules/custom/social_queue_storage/src/Form/QueueStorageEntityTypeForm.php, line 42

Class

QueueStorageEntityTypeForm
Class QueueStorageEntityTypeForm.

Namespace

Drupal\social_queue_storage\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $queue_storage_entity_type = $this->entity;
  $status = $queue_storage_entity_type
    ->save();
  switch ($status) {
    case SAVED_NEW:
      $this
        ->messenger()
        ->addMessage($this
        ->t('Created the %label Queue storage entity type.', [
        '%label' => $queue_storage_entity_type
          ->label(),
      ]));
      break;
    default:
      $this
        ->messenger()
        ->addMessage($this
        ->t('Saved the %label Queue storage entity type.', [
        '%label' => $queue_storage_entity_type
          ->label(),
      ]));
  }
  $form_state
    ->setRedirectUrl($queue_storage_entity_type
    ->toUrl('collection'));
}