protected function extractMessagesForDisplay(&$messages)
    {
        $output = [];
        
        if (empty($messages) || count($messages) == 0) {
            return $output;
        }
        
        foreach ($messages as $current) {
            $message_entry["message"] = $current["message"];
            
            if (!empty($current["code"])) {
                $message_entry["code"] = $current["code"];
            }
            
            if (!empty($current["auto_hide"])) {
                $message_entry["auto_hide"] = $this->getAutoHideTime();
            }
            
            if (!empty($current["details"]) && config_settings()->getParameter("show_message_details", false, 1)) {
                $message_entry["details"] = $current["details"];
            }
            
            $output[] = $message_entry;
        } // foreach
        
        // unset messages because they has been shown
        $messages = null;
        
        return $output;
    }