/** * Retourne la première erreur de la chaine d'exception au format ApiProblem. * @param \Exception $oException * @return \Commun\Model\LogApiProblem */ public static function tranformeExceptionToApiProblem($oException, $service) { $aReturn = ParseException::tranformeExceptionToArray($oException); // le code si supperieur a 599 est remplacer par 499. // pour plus de detail on met le code erreur original dans le type return new LogApiProblem($aReturn["code"], $aReturn['msg'], $aReturn['code'], $aReturn['type'], array(), $service); }
/** * Action pour la création. * * @return array */ public function createAction() { $oForm = new \Commun\Form\PallierAfficherForm(); //new \Commun\Form\PallierAfficherForm($this->getServiceLocator()); $oRequest = $this->getRequest(); $oFiltre = new \Commun\Filter\PallierAfficherFilter(); $oForm->setInputFilter($oFiltre->getInputFilter()); if ($oRequest->isPost()) { $oEntite = new \Commun\Model\PallierAfficher(); $oForm->setData($oRequest->getPost()); if ($oForm->isValid()) { // $oEntite->exchangeArray($oForm->getData()); $this->getTable()->beginTransaction(); try { $this->getTable()->saveOrUpdatePallier($oForm->getData()); $this->getTable()->commit(); $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Le pallier a été créé avec succès."), 'success'); return $this->redirect()->toRoute('backend-pallier-afficher-list'); } catch (\Exception $ex) { // on rollback en cas d'erreur $this->getTable()->rollback(); $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($ex); $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Une erreur est survenue lors de la création du pallier."), 'error'); $this->flashMessenger()->addMessage($aAjaxEx['msg'], 'error'); } } } // Pour optimiser le rendu $oViewModel = new ViewModel(); $oViewModel->setTemplate('backend/pallier-afficher/create'); return $oViewModel->setVariables(array('form' => $oForm)); }
/** * Action pour la mise à jour. * * @return array */ public function updateAction() { $id = (int) $this->params()->fromRoute('id', 0); try { $oEntite = $this->getTableRoster()->findRow($id); if (!$oEntite) { $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Identifiant de roster inconnu."), 'error'); return $this->redirect()->toRoute('backend-roster-list'); } } catch (\Exception $ex) { $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Une erreur est survenue lors de la récupération du roster."), 'error'); return $this->redirect()->toRoute('backend-roster-list'); } $oForm = new \Commun\Form\RosterForm(); //new \Commun\Form\RosterForm($this->getServiceLocator()); $oFiltre = new \Commun\Filter\RosterFilter(); $oEntite->setInputFilter($oFiltre->getInputFilter()); $oForm->bind($oEntite); $aOptRoster = array('nom' => $oEntite->getNom(), 'roles' => $this->getTableRole()->fetchAll()->toArray(), 'key' => $oEntite->getKey()); $oRequest = $this->getRequest(); if ($oRequest->isPost()) { $oForm->setInputFilter($oFiltre->getInputFilter()); $oForm->setData($oRequest->getPost()); if ($oForm->isValid()) { try { $this->getTableRoster()->beginTransaction(); $oEntite = $this->getTableRoster()->saveOrUpdateRoster($oEntite); $this->getTableRoster()->commit(); $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Le roster a été modifié avec succès."), 'success'); return $this->redirect()->toRoute('backend-roster-list'); } catch (\Exception $ex) { // on rollback en cas d'erreur $this->getTableRoster()->rollback(); $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($ex); $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("La modification du roster a échoué."), 'error'); $this->flashMessenger()->addMessage($this->_getServTranslator()->translate($aAjaxEx['msg']), 'error'); } } } // Pour optimiser le rendu $oViewModel = new ViewModel(); $oViewModel->setTemplate('backend/roster/update'); $oViewModel->setVariables(array('id' => $id, 'form' => $oForm, "roster" => $aOptRoster)); return $oViewModel; }
/** * Traitement de l'import Bnet. * * @return array */ public function importTraitementAction() { $aOptGuilde = array('guilde' => '', 'serveur' => '', 'lvlMin' => '', 'imp-membre' => 'Oui'); $this->layout('layout/ajax'); $oRequest = $this->getRequest(); if ($oRequest->isPost()) { $aPost = $oRequest->getPost(); try { $this->getTableGuilde()->beginTransaction(); $this->getTableGuilde()->importGuilde($aPost); $this->getTableGuilde()->commit(); $msg = $this->_getServTranslator()->translate("La guilde a été importé avec succès."); $this->getLogService()->log(LogService::INFO, $msg, LogService::USER, $aPost); // $this->flashMessenger()->addMessage($msg, 'success'); } catch (\Exception $exc) { // on rollback en cas d'erreur $this->getTableGuilde()->rollback(); $this->_getLogService()->log(LogService::ERR, $exc->getMessage(), LogService::USER, $aPost); $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($exc); $result = new JsonModel(array('error' => $aAjaxEx)); return $result; } } $result = new JsonModel(array('success' => array('msg' => $this->_getServTranslator()->translate('guilde importée avec succès')))); return $result; }
/** * Traitement de l'import Bnet. * * @return array */ public function importTraitementAction() { $aOptItem = array('id' => ''); $this->layout('layout/ajax'); //$this->layout('backend/layout'); $oRequest = $this->getRequest(); if ($oRequest->isPost()) { $aPost = $oRequest->getPost(); $this->getTable()->beginTransaction(); try { $this->getTable()->importItem($aPost); $this->getTable()->commit(); } catch (\Exception $ex) { // on rollback en cas d'erreur $this->getTable()->rollback(); $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($ex); $result = new JsonModel(array('error' => $aAjaxEx)); return $result; } } $result = new JsonModel(array('success' => array('msg' => $this->_getServTranslator()->translate('Item importé avec succès')))); return $result; }
/** * Traitement de l'import Bnet. * * @return array */ public function importTraitementAction() { $aOptPersonnage = array('nom' => '', 'serveur' => ''); $this->layout('layout/ajax'); //$this->layout('backend/layout'); $oRequest = $this->getRequest(); if ($oRequest->isPost()) { $aPost = $oRequest->getPost(); $this->getTablePersonnage()->beginTransaction(); try { $aPersoBnet = $this->getTablePersonnage()->importPersonnage($aPost); $oPersonnage = \Core\Util\ParserWow::extraitPersonnageDepuisBnet($aPersoBnet); $this->getTablePersonnage()->saveOrUpdatePersonnage($oPersonnage); $this->getTablePersonnage()->commit(); $msg = $this->_getServTranslator()->translate("Le personnage a été importé avec succès."); $this->_getLogService()->log(LogService::INFO, $msg, LogService::USER, $aPost); } catch (\Exception $exc) { // on rollback en cas d'erreur $this->getTablePersonnage()->rollback(); $this->_getLogService()->log(LogService::ERR, $exc->getMessage(), LogService::USER, $aPost); $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($exc); $result = new JsonModel(array('error' => $aAjaxEx)); return $result; } } $result = new JsonModel(array('success' => array('msg' => $this->_getServTranslator()->translate('Personnage importé avec succès')))); return $result; }
/** * Traitement de l'import eqdkp. * * @return array */ public function importTraitementAction() { $aOptImpRaid = array('serveur' => '', 'eqdkp' => '', 'nomRoster' => '', 'idRoster' => ''); $this->layout('layout/ajax'); $oRequest = $this->getRequest(); if ($oRequest->isPost()) { try { $aPost = $oRequest->getPost(); $this->getTableRaid()->beginTransaction(); if (!isset($aPost['idRoster']) || empty($aPost['idRoster'])) { $result = new JsonModel(array('error' => array('code' => 500, 'msg' => 'roster inconnu'))); return $result; } $aRaid = $this->importEqdkp($aPost['txtImport']); if (!isset($aRaid['head']['export']['name']) || $aRaid['head']['export']['name'] !== "EQdkp Plus XML") { $result = new JsonModel(array('error' => array('code' => 500, 'msg' => 'format XML non reconnu'))); return $result; } else { $this->saveImport($aRaid, $aPost); } $aRaid = $this->importEqdkp($aPost['txtImport']); $this->getTableRaid()->commit(); } catch (\Exception $ex) { // on rollback en cas d'erreur $this->getTableRaid()->rollback(); $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($ex); $result = new JsonModel(array('error' => $aAjaxEx)); return $result; } } $result = new JsonModel(array('success' => array('msg' => $this->_getServTranslator()->translate('Raid importée avec succès')))); return $result; }
/** * Action pour la majour des personnage du roster. * * @return array */ public function majAction() { $id = (int) $this->params()->fromRoute('id', 0); try { $oEntite = $this->getTableRoster()->findRow($id); if (!$oEntite) { $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Identifiant de roster inconnu."), 'error'); return $this->redirect()->toRoute('backend-roster-list'); } } catch (\Exception $ex) { $this->flashMessenger()->addMessage($this->_getServTranslator()->translate("Une erreur est survenue lors de la récupération du roster."), 'error'); return $this->redirect()->toRoute('backend-roster-list'); } $this->layout('layout/ajax'); $oRequest = $this->getRequest(); try { $oTabRosterHasPersonnage = $this->getTableRosterHasPersonnage()->select(array('idRoster' => $id)); if (isset($oTabRosterHasPersonnage)) { foreach ($oTabRosterHasPersonnage as $aCharacter) { $oPerso = $this->getTablePersonnage()->findRow($aCharacter['idPersonnage']); $aPersonnage = array('serveur' => $oPerso->getRoyaume(), 'nom' => $oPerso->getNom()); $aPersoBnet = $this->getTablePersonnage()->importPersonnage($aPersonnage); $oPersonnage = \Core\Util\ParserWow::extraitPersonnageDepuisBnet($aPersoBnet); $this->getTablePersonnage()->saveOrUpdatePersonnage($oPersonnage); } } return new JsonModel(array('success' => array('msg' => $this->_getServTranslator()->translate('Personnage mis à jour avec succès')))); } catch (\Exception $ex) { $aAjaxEx = \Core\Util\ParseException::tranformeExceptionToArray($ex); $result = new JsonModel(array('error' => $aAjaxEx)); return $result; } }