-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathFormSubmittedEvent.php
More file actions
45 lines (36 loc) · 1001 Bytes
/
FormSubmittedEvent.php
File metadata and controls
45 lines (36 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Forms\Events;
use OCA\Forms\Db\Form;
use OCA\Forms\Db\Submission;
class FormSubmittedEvent extends AbstractFormEvent {
public const TRIGGER_CREATED = 'created';
public const TRIGGER_UPDATED = 'updated';
public const TRIGGER_VERIFIED = 'verified';
public function __construct(
Form $form,
private Submission $submission,
private string $trigger = self::TRIGGER_CREATED,
) {
parent::__construct($form);
}
public function getSubmission(): Submission {
return $this->submission;
}
public function getTrigger(): string {
return $this->trigger;
}
public function isNewSubmission(): bool {
return $this->trigger === self::TRIGGER_CREATED;
}
public function getWebhookSerializable(): array {
return [
'form' => $this->form->read(),
'submission' => $this->submission->read(),
'trigger' => $this->trigger,
];
}
}