public function delete($id) { $existingUser = Module::getRepository('User')->findOneBy(array('merchant' => Module::getRepository('Merchant')->findOneBy(array('apiPrivateKey' => $id, 'apiPublicKey' => Module::getApiPublicKey())))); $user = false; $merchant = false; $address = false; if ($existingUser) { $mId = $existingUser->getMerchant()->getId(); $aId = $existingUser->getAddress()->getId(); $user = Module::removeEntity('User', $existingUser->getDocument(), 'document'); $address = Module::removeEntity('Address', $aId); $merchant = Module::removeEntity('Merchant', $mId); } return new JsonModel(array(array('success' => $user && $address && $merchant))); }
public function delete($id) { $merchantAuthenticated = Module::getRepository('Merchant')->findOneBy(array('apiPublicKey' => Module::getApiPublicKey())); if ($merchantAuthenticated && !empty($merchantAuthenticated->getApiPrivateKey())) { $existingUser = Module::getRepository('User')->findOneBy(array('integrationMerchant' => Module::getRepository('IntegrationMerchant')->findOneBy(array('apiPublicKey' => $id)))); $user = false; $integration_merchant = false; $address = false; if ($existingUser) { $iMId = $existingUser->getIntegrationMerchant()->getId(); $aId = $existingUser->getAddress()->getId(); $user = Module::removeEntity('User', $existingUser->getDocument(), 'document'); $address = Module::removeEntity('Address', $aId); $integration_merchant = Module::removeEntity('IntegrationMerchant', $iMId); } return new JsonModel(array(array('success' => $user && $address && $integration_merchant))); } return new JsonModel(array(array('success' => false))); }
private function config(MvcEvent $e) { $routeMatch = $e->getRouteMatch(); if ($routeMatch) { $headerContent = $e->getRequest()->getHeaders(); $merchantId = $headerContent->get('MERCHANT-ID'); $merchantLanguage = $headerContent->get('MERCHANT-LANGUAGE'); $mainKey = $headerContent->get('MAIN-KEY'); if (!$e->getRequest()->isPost() && $mainKey) { $mainKey = null; } if ($mainKey && !in_array($mainKey->getFieldValue(), Module::getMainKeys()) || !$mainKey && !$merchantId) { $e->getResponse()->setStatusCode(403); throw new \Exception('Request Not Authenticated'); } if ($mainKey) { Module::setMainKey($mainKey->getFieldValue()); } if ($merchantLanguage) { $systemLanguage = Module::getRepository('SystemLanguage')->findOneBy(array('name' => $merchantLanguage->getFieldValue())); if ($systemLanguage) { Module::setMerchantLanguage($merchantLanguage->getFieldValue()); } else { $e->getResponse()->setStatusCode(404); throw new \Exception('MERCHANT-LANGUAGE Is Not Found'); } } else { $e->getResponse()->setStatusCode(401); throw new \Exception('MERCHANT-LANGUAGE Not Specified'); } if ($merchantId) { $currentMerchant = Module::getRepository('Merchant')->findOneBy(array('language' => Module::getRepository('SystemLanguage')->findOneBy(array('name' => Module::getMerchantLanguage())), 'apiPublicKey' => $merchantId->getFieldValue())); if ($currentMerchant) { Module::setApiPublicKey($currentMerchant->getApiPublicKey()); } else { $e->getResponse()->setStatusCode(403); throw new \Exception('Request Not Authenticated'); } } } }
/** * Instanciar um Repositorio * * @param string $nameEntity * @return Doctrine\ORM\EntityRepository */ public function getRepository($nameEntity) { return Module::getRepository($nameEntity); }
public function getList() { $products = Module::getRepository('Product')->findBy(array('manufacturer' => Module::getRepository('Manufacturer')->findOneBy(array('platform' => Module::getRepository('Platform')->findOneBy(array('user' => Module::getRepository('User')->findOneBy(array('integrationMerchant' => Module::getRepository('IntegrationMerchant')->findOneBy(array('apiPublicKey' => Module::getApiPublicKey())))))))))); return new JsonModel($products); }
public function delete($id) { $existingUser = Module::getRepository('User')->findOneBy(array('integrationMerchant' => Module::getRepository('IntegrationMerchant')->findOneBy(array('merchant' => Module::getRepository('Merchant')->findOneBy(array('apiPublicKey' => Module::getApiPublicKey())))))); if ($existingUser) { if (!empty($existingUser->getMerchant()->getApiPrivateKey())) { $existingUser = Module::getRepository('User')->findOneBy(array('integrationMerchant' => Module::getRepository('IntegrationMerchant')->findOneBy(array('merchant' => Module::getRepository('Merchant')->findOneBy(array('apiPublicKey' => $id)))))); } else { $this->controller->getResponse()->setStatusCode(401); throw new \Exception('Request Not Authorized'); } } else { $existingUser = Module::getRepository('User')->findOneBy(array('integrationMerchant' => Module::getRepository('IntegrationMerchant')->findOneBy(array('merchant' => Module::getRepository('Merchant')->findOneBy(array('apiPrivateKey' => $id, 'apiPublicKey' => Module::getApiPublicKey())))))); } $user = false; $merchant = false; $address = false; if ($existingUser) { $mId = $existingUser->getMerchant()->getId(); $aId = $existingUser->getAddress()->getId(); $user = Module::removeEntity('User', $existingUser->getDocument(), 'document'); $address = Module::removeEntity('Address', $aId); $merchant = Module::removeEntity('Merchant', $mId); } return new JsonModel(array(array('success' => $user && $address && $merchant))); }