17 use Symfony\Component\HttpFoundation\Request;
18 use Symfony\Component\HttpFoundation\JsonResponse;
31 const NAME =
"ajax_license_acknowledgements";
39 function __construct()
41 parent::__construct(self::NAME,
43 self::REQUIRES_LOGIN =>
true,
46 $this->licenseAcknowledgementDao = $this->
getObject(
'dao.license.acknowledgement');
52 protected function handle(Request $request)
54 $toggleAcknowledgementPk = $request->get(
"toggle");
55 if ($toggleAcknowledgementPk !==
null) {
58 $status = $this->licenseAcknowledgementDao->toggleAcknowledgement(intval($toggleAcknowledgementPk));
59 }
catch (\UnexpectedValueException $e) {
60 $status = $e->getMessage();
62 return new JsonResponse([
"status" => $status]);
64 $reqScope = $request->get(
"scope",
"all");
65 $responseArray =
null;
66 if (strcasecmp($reqScope,
"all") === 0) {
67 $responseArray = $this->licenseAcknowledgementDao->getAllAcknowledgements();
68 }
else if (strcasecmp($reqScope,
"visible") === 0) {
69 $responseArray = $this->licenseAcknowledgementDao->getAllAcknowledgements(
true);
73 "acknowledgement" => $this->licenseAcknowledgementDao->getAcknowledgement(intval($reqScope))
75 }
catch (\UnexpectedValueException $e) {
78 "error" => $e->getMessage()
80 return new JsonResponse($responseArray, JsonResponse::HTTP_NOT_FOUND);
83 return new JsonResponse($responseArray, JsonResponse::HTTP_OK);
87 register_plugin(
new AjaxLicenseStdAcknowledgements());
Contains the constants and helpers for authentication of user.
handle(Request $request)
Load the license acknowledgements based on request type.
$licenseAcknowledgementDao