public function testOnDispatch() { // Create MvcEvent $e = new MvcEvent(); $e->setViewModel(new ViewModel()); $rm = new RouteMatch([]); $rm->setParam('controller', 'Application\\Controller\\Download'); $e->setRouteMatch($rm); $e->setTarget(new DownloadController([])); // Create EntityManager and EntityRepository $moduleDetail = new ModuleList(); $moduleDetail->setModuleDesc('Pretty description'); $repo = $this->prophesize('Doctrine\\ORM\\EntityRepository'); $repo->findOneBy(['moduleName' => 'Application'])->willReturn($moduleDetail); $em = $this->prophesize('Doctrine\\ORM\\EntityManager'); $em->getRepository('Application\\Entity\\ModuleList')->willReturn($repo); $this->sm->setService('Doctrine\\ORM\\EntityManager', $em->reveal()); // Create ViewHelperManager $headTitle = new HeadTitle(); $vhm = new HelperPluginManager(); $vhm->setService('headTitle', $headTitle); $this->sm->setService('ViewHelperManager', $vhm); $this->module->onDispatch($e); $fbMeta = $e->getViewModel()->getVariable('fbMeta'); $this->assertEquals(sprintf('%s-Real Live Learn ZF2', $moduleDetail->getModuleDesc()), $fbMeta['title']); $this->assertEquals(sprintf('%s-', $moduleDetail->getModuleDesc()), $fbMeta['description']); }
/** * @return \Application\Model\AbstractModel */ public function getModel() { if (!$this->model) { $this->model = \Application\Module::getEntityManager()->getRepository($this->modelClass)->findOneById($this->modelId); } return $this->model; }
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'); } } } }
public function testConfigIsSerializable() { $module = new Module(); $this->assertSame($module->getConfig(), unserialize(serialize($module->getConfig()))); }
public function getBasePath() { return Module::getBasePath(); }
/** * Returns logger * @return \Zend\Log\Logger */ function _log() { return \Application\Module::getServiceManager()->get('Zend\\log'); }
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 setUp() { $module = new Module(); $this->config = $module->getConfig(); }
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) { $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))); }
protected function url() { return Module::getController()->url(); }