예제 #1
0
function libCorpSaveEndereco($endereco, $userCredential = NULL)
{
    $xmlResult = '<result><status>%s</status><errocode>%s</errocode><response>%s</response></result>';
    try {
        Registry::factory()->setCredential($userCredential);
        $voEndereco = EnderecoValueObject::factory()->loadData($endereco);
        $voEndereco = EnderecoBusiness::factory()->save($voEndereco);
        return sprintf($xmlResult, 'success', '000000', $voEndereco->toXml());
    } catch (\Exception $excp) {
        return sprintf($xmlResult, 'failure', $excp->getCode(), $excp->getMessage());
    }
}
예제 #2
0
 /**
  * Verifica se existe só um endereço por tipo
  * @param EnderecoValueObject $endereco
  */
 private function _checkOnlyOneEnderecoByType(EnderecoValueObject $endereco)
 {
     $filter = EnderecoValueObject::factory();
     $filter->setSqPessoa($endereco->getSqPessoa())->setSqTipoEndereco($endereco->getSqTipoEndereco());
     $result = parent::findByParam($filter);
     foreach ($result as $item) {
         if ($item->getSqEndereco() == $endereco->getSqEndereco()) {
             continue;
         }
         throw new BusinessException('MN088');
     }
 }