Add call to trigger before saving shadow attribute

pull/9589/head
Vincenzo Caputo 2024-02-25 15:54:42 +00:00
parent 02de43a49e
commit eca3cd9cbf
1 changed files with 17 additions and 0 deletions

View File

@ -196,6 +196,23 @@ class ShadowAttribute extends AppModel
// convert into utc and micro sec
$this->data = $this->Attribute->ISODatetimeToUTC($this->data, $this->alias);
$trigger_id = 'shadow-attribute-before-save';
$isTriggerCallable = $this->isTriggerCallable($trigger_id);
if ($isTriggerCallable) {
$triggerData = $this->data;
$workflowErrors = [];
$logging = [
'model' => 'ShadowAttribute',
'action' => 'add',
'id' => $this->data['ShadowAttribute']['id'],
'message' => __('The workflow `%s` prevented the saving of this proposal.', $trigger_id)
];
$workflowSuccess = $this->executeTrigger($trigger_id, $triggerData, $workflowErrors, $logging);
if (!$workflowSuccess) {
return false;
}
}
return true;
}