/**
  * Edit function for saving simple document
  * @param xml object $data data to be updated
  * @return array
  */
 public function edit($data)
 {
     //get data from fields when using epath to send data
     if (isset($data->fields)) {
         return parent::edit($data->fields);
     } else {
         return parent::edit($data);
     }
 }
 /**
  * deleteSystemEmailIfNoMergeFields
  * @param XML $data tags
  * @return void
  */
 public function deleteSystemEmailIfNoMergeFields($data)
 {
     $this->_documentClassName = 'MoveIn4Activity\\Document\\ActivitySystemEmailDocument';
     if (count($data->mergeFields) == 0) {
         $data->deleted = true;
         unset($data->mergeFields);
         return parent::edit($data);
     } else {
         return ['status' => "done"];
     }
 }
 /**
  * get one system email
  * @param xml object $data data to be updated
  * @return array
  */
 public function getSystemTemplateDocumentForNewTemplateDocument($data)
 {
     $return = parent::getOne($data);
     foreach ($return['fields'] as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $sKey => $sValue) {
                 if (isset($sValue['id'])) {
                     $return['fields'][$key][$sKey] = $sValue['id'];
                 }
             }
         }
     }
     unset($return['fields']['id']);
     return $return;
 }
 /**
  * save and edit system template document
  * @param unknown $data data
  * @return Ambigous <multitype:, multitype:Ambigous <boolean, \Base\Model\Service\Ambigous, multitype:, string, unknown, object> NULL >
  */
 public function edit($data)
 {
     if (isset($data->fields)) {
         $recipient = $data->fields->addChild('recipient');
         $recipient->addChild('documentId', (string) $data->recipient->documentId);
         $recipient->addChild('person', (string) $data->recipient->person);
         $auth = $data->fields->addChild('auth');
         foreach ((array) $data->auth as $index => $value) {
             $auth->addChild($index, $value);
         }
         return parent::edit($data->fields);
     } else {
         return parent::edit($data);
     }
 }