public function pesquisar($strCEP) { $adapter = $this->getAdapter(); $arrResult = $adapter->pesquisaCep(Format::clearMask($strCEP)); if (!$arrResult['status']) { throw new \Exception($arrResult['message']); } $arrResult = $this->makeResult($arrResult); // if (array_key_exists('idMunicipio', $arrResult)) { // # operacao de cadastro // } return $arrResult; }
public function save($arrData) { try { if ($arrData['idEmpreendimento']) { $empreendimento = $this->find($arrData['idEmpreendimento']); } else { $empreendimento = new EmpreendimentoEntity(); } $empreendimento->setCoCep(Format::clearMask($arrData['coCep']))->setDsBairro($arrData['dsBairro'])->setDsComplemento($arrData['dsComplemento'])->setDsEmpreendimento($arrData['dsEmpreendimento'])->setDsLogradouro($arrData['dsLogradouro'])->setIdMunicipio($this->getReferenceEntity($arrData['coMunicipio'], 'Application\\Entity\\Municipio'))->setInSituacao(EmpreendimentoEntity::co_situacao_ativo); $this->getEntityManager()->persist($empreendimento); $this->getEntityManager()->flush(); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } }