You are here

function PushNotificationForm::updateStatus in Push Notifications 8

Entity builder updating the push_notification status with the submitted value and also sent the push notification.

Parameters

string $entity_type_id: The entity type identifier.

\Drupal\push_notifications\PushNotificationInterface $push_notification: The push_notification updated with the submitted values.

array $form: The complete form array.

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

See also

\Drupal\push_notifications\Form\PushNotificationForm::form()

File

src/Form/PushNotificationForm.php, line 141
Contains Drupal\push_notifications\Form\PushNotificationForm.

Class

PushNotificationForm
Form controller for the push_notification entity edit forms.

Namespace

Drupal\push_notifications\Form

Code

function updateStatus($entity_type_id, PushNotificationInterface $push_notification, array $form, FormStateInterface $form_state) {
  $element = $form_state
    ->getTriggeringElement();
  if (isset($element['#pushed_status'])) {
    if ($push_notification
      ->setPushed($element['#pushed_status'])) {

      // @todo: Send notification
      $values = $form_state
        ->getValues();
      drupal_set_message($this
        ->t('The push notification has been successfully send.'));
    }
  }
}