From f753ba9996fe2e55be304f5600c01d5d8edfc079 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 5 Aug 2024 09:44:43 +0000 Subject: [PATCH] WIP actions hooks --- ...eCommunityEngagementMilestonesProgress.php | 4 + code/web/sys/DB/DataObject.php | 7 +- code/web/sys/action-hooks.php | 80 +++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 code/web/cron/updateCommunityEngagementMilestonesProgress.php create mode 100644 code/web/sys/action-hooks.php diff --git a/code/web/cron/updateCommunityEngagementMilestonesProgress.php b/code/web/cron/updateCommunityEngagementMilestonesProgress.php new file mode 100644 index 0000000000..f71e598ba4 --- /dev/null +++ b/code/web/cron/updateCommunityEngagementMilestonesProgress.php @@ -0,0 +1,4 @@ +getSerializedFieldNames(); $compressedFields = $this->getCompressedColumnNames(); + do_action('before_object_insert', get_object_vars($this)); + $properties = get_object_vars($this); $propertyNames = ''; $propertyValues = ''; @@ -408,6 +410,9 @@ public function insert($context = '') { } } + #Call hook for post insert here + do_action('after_object_insert', $this); + return $response; } diff --git a/code/web/sys/action-hooks.php b/code/web/sys/action-hooks.php new file mode 100644 index 0000000000..fce15601a5 --- /dev/null +++ b/code/web/sys/action-hooks.php @@ -0,0 +1,80 @@ +query("SELECT sourceId from {$tableName} WHERE sourceId = {$value['sourceId']}"); + if ($checkOuts->getNumResults() > 0) { + return; + } + + # Add entry to ce_milestone_goal_actions + +}); + +// Example of action hook +// add_action('after_object_insert', 'after_checkout_insert', function($value){ + +// $tableName = 'user_checkout'; + +// # Bail if not the table we want +// if($value->__table != $tableName) return; + +// # Bail if the newly created checkout already exists +// $checkOuts = new CheckOut(); +// $checkOuts->query("SELECT sourceId from {$tableName} WHERE sourceId = {$value->sourceId}"); +// if ($checkOuts->getNumResults() > 0) { +// return; +// } + + +// }); \ No newline at end of file