/**

     * Create Message-Type records

     *

     * @param array $arrayData Data

     *

     * return void

     */

    public function createMessageType(array $arrayData)

    {

        try {

            $messageType = new \ProcessMaker\BusinessModel\MessageType();



            foreach ($arrayData as $value) {

                $record = $value;



                if ($messageType->exists($record["MSGT_UID"])) {

                    $messageType->delete($record["MSGT_UID"]);

                }



                $result = $messageType->singleCreate($record);

            }

        } catch (Exception $e) {

            throw $e;

        }

    }
 /**
  * Set Message-Event-Definition-Variables by Message-Type for a record
  *
  * @param array $record Record
  *
  * return array Return the record
  */
 public function setMessageEventDefinitionVariablesForRecordByMessageType(array $record)
 {
     try {
         $record["MSGED_VARIABLES"] = $record["MSGED_VARIABLES"] . "" != "" ? unserialize($record["MSGED_VARIABLES"]) : array();
         if ($record["MSGT_UID"] . "" != "") {
             $arrayMessageTypeVariable = array();
             $messageType = new \ProcessMaker\BusinessModel\MessageType();
             if ($messageType->exists($record["MSGT_UID"])) {
                 $arrayMessageTypeData = $messageType->getMessageType($record["MSGT_UID"], true);
                 foreach ($arrayMessageTypeData["MSGT_VARIABLES"] as $value) {
                     $arrayMessageTypeVariable[$value["MSGTV_NAME"]] = isset($record["MSGED_VARIABLES"][$value["MSGTV_NAME"]]) ? $record["MSGED_VARIABLES"][$value["MSGTV_NAME"]] : $value["MSGTV_DEFAULT_VALUE"];
                 }
             }
             $record["MSGED_VARIABLES"] = $arrayMessageTypeVariable;
         }
         //Return
         return $record;
     } catch (\Exception $e) {
         throw $e;
     }
 }