You are here

public function GroupDeleteForm::save in Entity Share 8

Same name and namespace in other branches
  1. 8.3 modules/entity_share_server/src/Form/GroupDeleteForm.php \Drupal\entity_share_server\Form\GroupDeleteForm::save()
  2. 8.2 modules/entity_share_server/src/Form/GroupDeleteForm.php \Drupal\entity_share_server\Form\GroupDeleteForm::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/entity_share_server/src/Form/GroupDeleteForm.php, line 47

Class

GroupDeleteForm
Class GroupDeleteForm.

Namespace

Drupal\entity_share_server\Form

Code

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

  /** @var \Drupal\entity_share_server\Entity\ChannelInterface $channel */
  $channel = $this->entity;
  $channel_groups = $channel
    ->get('channel_groups');
  unset($channel_groups[$this
    ->getgroupId()]);
  $channel
    ->set('channel_groups', $channel_groups);
  $channel
    ->save();
  $form_state
    ->setRedirectUrl($channel
    ->toUrl('edit-form'));
}