Skip to content

Allow configurating on which submission states handlers should run - #333

Open
jekuaitk wants to merge 3 commits into
OS2Forms:developfrom
itk-dev:feature/add-states-configuration-to-handlers
Open

jekuaitk wants to merge 3 commits into
OS2Forms:developfrom
itk-dev:feature/add-states-configuration-to-handlers

Conversation

@jekuaitk

@jekuaitk jekuaitk commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #334

When using digital signature other handlers should be modified to run on "locked" submission state.

This PR adds configuration to handlers that allow stating on which states the handler should run, akin to the e-mail handler.

The default state on which handlers run are "completed".

@ds-bellcom

Copy link
Copy Markdown
Contributor

333: @OS2Forms/koordinationsgruppe vi estimerer 2,5 timer til review af denne. Vil I godkende?

@jekuaitk

jekuaitk commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Handler states does not make sense under the context of Digital Signature - therefore it has been removed.

However, signature doesn't make sense on draft, so this has been added to the states in which the signature flow should not run!

@stankut stankut left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only two things i could find, which are similar in all three handlers 😄

public const ATTACHMENT_ELEMENT = 'attachment_element';
public const SENDER_ADDRESS = 'sender_address';
private const string ADDITIONAL = 'additional';
private const string STATES = 'states';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typed class constants require PHP 8.3, while this package still declares "php": "^8.1". On PHP 8.1/8.2, loading any of these three handlers will cause a parse error, breaking forms that use them.

We either need to remove string type here or bump the PHP version in composer.json

WebformSubmissionInterface::STATE_CONVERTED => $this->t('anonymous <b>submission is converted</b> to authenticated.'),
WebformSubmissionInterface::STATE_COMPLETED => $this->t('<b>submission is completed</b>.'),
WebformSubmissionInterface::STATE_UPDATED => $this->t('<b>submission is updated</b>.'),
WebformSubmissionInterface::STATE_DELETED => $this->t('<b>submission is deleted</b>.'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler only processes states in postSave(), but deleting a submission invokes postDelete() instead. Therefore selecting “submission is deleted” can never trigger this handler.

Please either implement the corresponding delete hook or remove STATE_DELETED from the available options.

public const FASIT_HANDLER_CPR_ELEMENT = 'cpr_element';
public const FASIT_HANDLER_ATTACHMENT_ELEMENT = 'attachment_element';
private const string ADDITIONAL = 'additional';
private const string STATES = 'states';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typed class constants require PHP 8.3, while this package still declares "php": "^8.1". On PHP 8.1/8.2, loading any of these three handlers will cause a parse error, breaking forms that use them.

We either need to remove string type here or bump the PHP version in composer.json

WebformSubmissionInterface::STATE_CONVERTED => $this->t('anonymous <b>submission is converted</b> to authenticated.'),
WebformSubmissionInterface::STATE_COMPLETED => $this->t('<b>submission is completed</b>.'),
WebformSubmissionInterface::STATE_UPDATED => $this->t('<b>submission is updated</b>.'),
WebformSubmissionInterface::STATE_DELETED => $this->t('<b>submission is deleted</b>.'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler only processes states in postSave(), but deleting a submission invokes postDelete() instead. Therefore selecting “submission is deleted” can never trigger this handler.

Please either implement the corresponding delete hook or remove STATE_DELETED from the available options.

*/
private const QUEUE_ID = 'os2forms_fbs_handler';
private const string ADDITIONAL = 'additional';
private const string STATES = 'states';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typed class constants require PHP 8.3, while this package still declares "php": "^8.1". On PHP 8.1/8.2, loading any of these three handlers will cause a parse error, breaking forms that use them.

We either need to remove string type here or bump the PHP version in composer.json

WebformSubmissionInterface::STATE_CONVERTED => $this->t('anonymous <b>submission is converted</b> to authenticated.'),
WebformSubmissionInterface::STATE_COMPLETED => $this->t('<b>submission is completed</b>.'),
WebformSubmissionInterface::STATE_UPDATED => $this->t('<b>submission is updated</b>.'),
WebformSubmissionInterface::STATE_DELETED => $this->t('<b>submission is deleted</b>.'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler only processes states in postSave(), but deleting a submission invokes postDelete() instead. Therefore selecting “submission is deleted” can never trigger this handler.

Please either implement the corresponding delete hook or remove STATE_DELETED from the available options.

@ds-bellcom

Copy link
Copy Markdown
Contributor

Please wait to merge this PR until the Drupal 11 release is out.

@ds-bellcom

Copy link
Copy Markdown
Contributor

@jekuaitk this PR may be merged to develop-branch when the corrections is made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

States on which handlers should run

4 participants