$trigger::getPosition(), 'trigger' => $trigger, ]; } $actionsToSort = []; foreach ($actions as $action) { $actionsToSort[$action::getType()] = [ 'position' => $action::getPosition(), 'action' => $action, ]; } $sortedTriggers = $this->sortArray($triggersToSort); foreach ($sortedTriggers as $sorted) { $trigger = $sorted['trigger']; $this->triggers[$trigger::getType()] = $trigger; } $sortedActions = $this->sortArray($actionsToSort); foreach ($sortedActions as $sorted) { $action = $sorted['action']; $this->actions[$action::getType()] = $action; } } private function sortArray($array) { usort($array, function ($a, $b) { return $a['position'] - $b['position']; }); return $array; } /** * @return AbstractTrigger[] */ public function getTriggers() { return $this->triggers; } /** * @return TriggerInterface */ public function getTrigger($type) { return $this->triggers[$type]; } public function getActions() { return $this->actions; } /** * @return ActionInterface */ public function getAction($type) { return $this->actions[$type]; } }