/** * @param $request * @return SS_HTTPResponse|string */ public function emitPackagePurchaseOrder($request) { if (!Director::is_ajax()) { return $this->forbiddenError(); } if (!$this->packagePurchaseOrderSecurityToken->checkRequest($request)) { return $this->forbiddenError(); } $body = $this->request->getBody(); $json = json_decode($body, true); $this->packagePurchaseOrderSecurityToken->reset(); try { $this->getPackagePurchaseOrderManager()->registerPurchaseOrder($json, new NewPurchaseOrderEmailMessageSender()); } catch (EntityValidationException $ex1) { SS_Log::log($ex1, SS_Log::WARN); return $this->validationError($ex1->getMessages()); } catch (Exception $ex) { SS_Log::log($ex, SS_Log::ERR); return $this->serverError(); } return $this->ok(array('token' => $this->packagePurchaseOrderSecurityToken->getValue())); }
function testNamedTokensCarryDifferentValues() { $t1 = new SecurityToken('one'); $t2 = new SecurityToken('two'); $this->assertNotEquals($t1->getName(), $t2->getName()); $this->assertNotEquals($t1->getValue(), $t2->getValue()); }