17 use Symfony\Component\HttpFoundation\Request;
18 use Symfony\Component\HttpFoundation\JsonResponse;
31 const NAME =
"ajax_license_std_comments";
39 function __construct()
41 parent::__construct(self::NAME,
43 self::REQUIRES_LOGIN =>
true,
46 $this->licenseCommentDao = $this->
getObject(
'dao.license.stdc');
52 protected function handle(Request $request)
54 $toggleCommentPk = $request->get(
"toggle");
55 if ($toggleCommentPk !==
null) {
58 $status = $this->licenseCommentDao->toggleComment(intval($toggleCommentPk));
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->licenseCommentDao->getAllComments();
68 }
else if (strcasecmp($reqScope,
"visible") === 0) {
69 $responseArray = $this->licenseCommentDao->getAllComments(
true);
73 "comment" => $this->licenseCommentDao->getComment(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 AjaxLicenseStdComments());
Contains the constants and helpers for authentication of user.