Created
April 3, 2014 14:05
-
-
Save gpfiel/9954980 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Persistir o objeto da mensagem, verifica se irá alterar ou cadastrar | |
* @param EntityManager $em | |
* @param Resposta &$objResposta | |
* @return Array Dados necessários para o registro do log | |
*/ | |
public function persistir(EntityManager $em, Resposta &$objResposta) | |
{ | |
$em->getFilters()->disable('soft_delete'); | |
$logTipo = LogTipo::REMOVER; | |
$objReferenciado = $em->getRepository("Application\Entity\ContaFornecedor")->findOneBy(array("idExterno" => $this->getCodigoFornecedor())); | |
$MSG0069R1 = new MSG0069R1(); | |
$idObjReferenciado = ""; | |
if (! is_null($objReferenciado)) { | |
$idObjReferenciado = $objReferenciado->getId(); | |
try { | |
$em->remove($objReferenciado); | |
$em->flush(); | |
$MSG0069R1->setSucesso("true"); | |
} catch (\Exception $e) { | |
$MSG0069R1->setSucesso("false"); | |
$MSG0069R1->setCodigoErro(200); | |
echo '<pre>'; | |
print_r($e->getMessage()); | |
exit; | |
$MSG0069R1->setMensagem('Falha na execução da operação: '. $e->getMessage()); | |
} | |
} else { | |
$MSG0069R1->setSucesso("false"); | |
$MSG0069R1->setCodigoErro(200); | |
$MSG0069R1->setMensagem('Não foi possível encontrar a Conta referência.'); | |
} | |
$objResposta->resposta = $MSG0069R1->getXmlBaseAsString(); | |
$em->getFilters()->enable('soft_delete'); | |
return array("id" => "ID do objeto referenciado: " . $idObjReferenciado, "logTipo" => $logTipo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment