public function WebformProtectedDownloadsHandler::postSave in Webform Protected Downloads 8
Acts on a saved webform submission before the insert or update hook is invoked.
Parameters
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.
Overrides WebformHandlerBase::postSave
File
- src/
Plugin/ WebformHandler/ WebformProtectedDownloadsHandler.php, line 239
Class
- WebformProtectedDownloadsHandler
- Handler for protected downloads
Namespace
Drupal\webform_protected_downloads\Plugin\WebformHandlerCode
public function postSave(WebformSubmissionInterface $webform_submission, $update = TRUE) {
// only act on the insert
if (!$update) {
return;
}
// only process if there are files added to the configuration
if (count($this->configuration['protected_files']) > 0) {
return;
}
$expiration = 0;
if ($this->configuration['expiration_time'] > 0) {
$expiration = time() + $this->configuration['expiration_time'] * 60;
}
// TODO
// $webformProtectedDownload = WebformProtectedDownloads::create([
// 'webform_submission' => $webform_submission,
// 'files' => $this->con,
// 'hash' => Crypt::hashBase64($webform_submission->uuid() . time()),
// 'active' => TRUE,
// 'expire' => $expiration,
// 'onetime' => $this->configuration['expiration_onetime'],
// ]);
//
// $webformProtectedDownload->save();
}