public function salvar(DespesaCategoria $objDespesaCategoria)
 {
     $arrayDespesaCategoria = array_filter($objDespesaCategoria->getArrayCopy());
     $id = (int) $objDespesaCategoria->id;
     if ($id == 0) {
         return $this->insert($arrayDespesaCategoria);
     } else {
         if ($this->buscarUm($id)) {
             var_dump($arrayDespesaCategoria);
             die;
             return $this->update($arrayDespesaCategoria, ['id' => $id]);
         }
         throw new \Exception('Registro não encontrado.');
     }
 }
 public function salvarAction()
 {
     $form = $this->getDespesaCategoriaForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $despesaCategoria = new DespesaCategoria();
             $despesaCategoria->exchangeArray($form->getData());
             $retorno = $this->getDespesaCategoriaTabela()->salvar($despesaCategoria);
             if ($retorno) {
                 $this->flashMessenger()->addSuccessMessage('Registro salvo com sucesso.');
                 return $this->redirect()->toRoute('despesa-categoria');
             } else {
                 $this->flashMessenger()->addErrorMessage('Erro ao salvar registro, tente novamente.');
             }
         }
     }
     $arrayCliente = $this->getClienteTabela()->buscarTodos(false);
     return array('form' => $form, 'fk_cliente' => array_column($arrayCliente->toArray(), 'nome', 'id'));
 }