Skip to content

Commit

Permalink
Event trigger order based on their priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Alistair Kearney authored and Alistair Kearney committed Dec 23, 2009
1 parent e0337b2 commit 2a8fc6e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions symphony/lib/toolkit/class.frontendpage.php
Expand Up @@ -501,6 +501,13 @@ public function __processDatasources($datasources, &$wrapper) {
}
}

private function __findEventOrder($a, $b){
if ($a->priority() == $b->priority()) {
return 0;
}
return(($a->priority() > $b->priority()) ? -1 : 1);
}

private function __processEvents($events, &$wrapper){

####
Expand All @@ -524,15 +531,20 @@ private function __processEvents($events, &$wrapper){
$events = array_map('trim', $events);

if(!is_array($events) || empty($events)) return;


$pool = array();
foreach($events as $handle){
$pool[$handle] = $this->EventManager->create($handle, array('env' => $this->_env, 'param' => $this->_param));
}

uasort($pool, array($this, '__findEventOrder'));

foreach($pool as $handle => $event){
$this->_Parent->Profiler->seed();

$dbstats = Symphony::Database()->getStatistics();
$queries = $dbstats['queries'];

$event = $this->EventManager->create($handle, array('env' => $this->_env, 'param' => $this->_param));


if($xml = $event->load()):

if(is_object($xml)) $wrapper->appendChild($xml);
Expand Down

0 comments on commit 2a8fc6e

Please sign in to comment.