From f25e5e3860949b6fdcfd1cfeda062cf0bb36832e Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Fri, 27 Feb 2015 12:11:43 +0100 Subject: [PATCH] Start and EndActionExecute added/fixed/documented --- EVENTS.txt | 7 +++++++ lib/action.php | 14 ++++++++------ plugins/Cronish/CronishPlugin.php | 2 +- plugins/OpportunisticQM/OpportunisticQMPlugin.php | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 088ce8c024..caa99f9638 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -2,6 +2,13 @@ InitializePlugin: a chance to initialize a plugin in a complete environment CleanupPlugin: a chance to cleanup a plugin at the end of a program +StartActionExecute: Right before the "prepare" call of the current Action +- $action: the current Action object +- &$args: array of arguments, referenced so you can modify the array + +EndActionExecute: Right after the "handle" call of the current Action +- $action: the current Action object + StartPrimaryNav: Showing the primary nav menu - $action: the current action diff --git a/lib/action.php b/lib/action.php index 7c57cbc432..3b3d21680e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -118,16 +118,18 @@ class Action extends HTMLOutputter // lawsuit common_config_set('db', 'database', $mirror); } - $status = $this->prepare($args); - if ($status) { - $this->handle($args); - } else { - common_debug('Prepare failed for Action.'); + if (Event::handle('StartActionExecute', array($this, &$args))) { + $prepared = $this->prepare($args); + if ($prepared) { + $this->handle($args); + } else { + common_debug('Prepare failed for Action.'); + } } $this->flush(); - Event::handle('EndActionExecute', array($status, $this)); + Event::handle('EndActionExecute', array($this)); } /** diff --git a/plugins/Cronish/CronishPlugin.php b/plugins/Cronish/CronishPlugin.php index fb12000c46..9ae62dc778 100644 --- a/plugins/Cronish/CronishPlugin.php +++ b/plugins/Cronish/CronishPlugin.php @@ -37,7 +37,7 @@ class CronishPlugin extends Plugin { * When the page has finished rendering, let's do some cron jobs * if we have the time. */ - public function onEndActionExecute($status, Action $action) + public function onEndActionExecute(Action $action) { $cron = new Cronish(); $cron->callTimedEvents(); diff --git a/plugins/OpportunisticQM/OpportunisticQMPlugin.php b/plugins/OpportunisticQM/OpportunisticQMPlugin.php index 89bd15a1a0..2e57cae9d1 100644 --- a/plugins/OpportunisticQM/OpportunisticQMPlugin.php +++ b/plugins/OpportunisticQM/OpportunisticQMPlugin.php @@ -14,7 +14,7 @@ class OpportunisticQMPlugin extends Plugin { * When the page has finished rendering, let's do some cron jobs * if we have the time. */ - public function onEndActionExecute($status, Action $action) + public function onEndActionExecute(Action $action) { if ($action instanceof RunqueueAction) { return true; -- 2.39.5