44 const NAME =
"ajax_license_std_comments";
52 function __construct()
54 parent::__construct(self::NAME,
56 self::REQUIRES_LOGIN =>
true,
59 $this->licenseCommentDao = $this->
getObject(
'dao.license.stdc');
65 protected function handle(Request $request)
67 $toggleCommentPk = $request->get(
"toggle");
68 if ($toggleCommentPk !== null) {
71 $status = $this->licenseCommentDao->toggleComment(intval($toggleCommentPk));
72 }
catch (\UnexpectedValueException $e) {
73 $status = $e->getMessage();
75 return new JsonResponse([
"status" => $status]);
77 $reqScope = $request->get(
"scope",
"all");
78 $responseArray = null;
79 if (strcasecmp($reqScope,
"all") === 0) {
80 $responseArray = $this->licenseCommentDao->getAllComments();
81 }
else if (strcasecmp($reqScope,
"visible") === 0) {
82 $responseArray = $this->licenseCommentDao->getAllComments(
true);
86 "comment" => $this->licenseCommentDao->getComment(intval($reqScope))
88 }
catch (\UnexpectedValueException $e) {
91 "error" => $e->getMessage()
93 return new JsonResponse($responseArray, JsonResponse::HTTP_NOT_FOUND);
96 return new JsonResponse($responseArray, JsonResponse::HTTP_OK);