Accessor for comment requests

@return CommentRequests
346336
public function comments()
    {
        if (is_null($this->commentRequests)) {
            $this->commentRequests = new CommentRequests($this->client);
        }

        return $this->commentRequests;
    }
777962
protected function getCommentSections()
    {
        if (empty($this->commentSections) && $this->rawComment) {
            $this->commentSections = explode("\n\n", $this->rawComment);
        }

        return $this->commentSections;
    }
177958
public function addComment()
    {
        $userIsAllowed = $this
            ->userCredentialsProvider
            ->isAllowed();
        if (!$userIsAllowed) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'The user is not allowed to post a comment',
            ], 401);
        }

        $sourceUUID = $this->getSourceUUID();
        if (empty($sourceUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Source UUID header must be defined',
            ], 400);
        }

        $authorUUID = $this
            ->userCredentialsProvider
            ->getUUID();
        if (empty($authorUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Author UUID header must be defined',
            ], 400);
        }

        $now = new DateTime();
        $postParameterBag = $this
            ->request
            ->request;

        $authorIsModerator = $this->userCredentialsProvider->isModerator();
        $authorRole = $authorIsModerator
            ? Author::ROLE_MODERATOR
            : Author::ROLE_USER;

        $state = $authorIsModerator
            ? State::APPROVED
            : State::NEW;

        $comment = Comment::createFromArray([
            'id' => bin2hex(random_bytes(32)),
            'source' => $sourceUUID,
            'author_uuid' => $authorUUID,
            'author_name' => $this->userCredentialsProvider->getName(),
            'author_email' => $this->userCredentialsProvider->getEmail(),
            'author_avatar' => $this->userCredentialsProvider->getAvatar(),
            'author_role' => $authorRole,
            'content' => $postParameterBag->get('content'),
            'created_at' => $now->format(DATE_ATOM),
            'state' => $state,
            'rating' => (int) $postParameterBag->get('rating', 0),
        ]);

        $this
            ->commentRepository
            ->addComment($comment);
        $this->flushRepository();
        $comment->setEditable(true);

        return new JsonResponse([
            'status' => 'OK',
            'comment' => $comment->toArray(),
            'user' => $this->userCredentialsProvider->toArray(),
        ], 200);
    }
73333
public function getCommentCount()
    {
        return count(Comment::findAll([
            'parent_id' => $this->id,
            'model' => self::COMMENT_FOR,
            'status' => Comment::STATUS_APPROVED
        ]));
    }
1181508
public List<Comment> getComments(String commentsUrl, GitHubRepo repo) throws RestClientException {

        List<Comment> comments = new ArrayList<>();

        // decrypt password
        String decryptedPassword = decryptString(repo.getPassword(), settings.getKey());

        String personalAccessToken = (String) repo.getOptions().get("personalAccessToken");
        String decryptedPersonalAccessToken = decryptString(personalAccessToken, settings.getKey());

        boolean lastPage = false;
        String queryUrlPage = commentsUrl;
        while (!lastPage) {
            ResponseEntity<String> response = makeRestCall(queryUrlPage, repo.getUserId(), decryptedPassword,decryptedPersonalAccessToken);
            JSONArray jsonArray = parseAsArray(response);
            for (Object item : jsonArray) {
                JSONObject jsonObject = (JSONObject) item;

                Comment comment = new Comment();
                JSONObject userJsonObj = (JSONObject) jsonObject.get("user");
                comment.setUser((String) userJsonObj.get("login"));
                long crt = new DateTime(str(jsonObject, "created_at")).getMillis();
                comment.setCreatedAt(crt);
                long upd = new DateTime(str(jsonObject, "updated_at")).getMillis();
                comment.setUpdatedAt(upd);
                comment.setBody(str(jsonObject, "body"));
                comments.add(comment);
            }
            if (CollectionUtils.isEmpty(jsonArray)) {
                lastPage = true;
            } else {
                if (isThisLastPage(response)) {
                    lastPage = true;
                } else {
                    lastPage = false;
                    queryUrlPage = getNextPageUrl(response);
                }
            }
        }
        return comments;
    }
767554
def get_comments(self):
        
        return github.PaginatedList.PaginatedList(
            github.CommitComment.CommitComment,
            self._requester,
            self.url + "/comments",
            None
        )
505776
protected function getModifiersComment()
    {
        $modifiersComment = null;

        foreach ($this->getCommentSections() as $commentSection) {
            // Assume that the modifiers section starts with either a class or a
            // pseudo class
            if (preg_match('/^\s*(?:\.|:)/', $commentSection)) {
                $modifiersComment = $commentSection;
                break;
            }
        }

        return $modifiersComment;
    }
848553
def get_comments_by_search(self, comment_query, comment_search):
        """"""
        # Implemented from azosid template for -
        # osid.resource.ResourceSearchSession.get_resources_by_search_template
        if not self._can('search'):
            raise PermissionDenied()
        return self._provider_session.get_comments_by_search(comment_query, comment_search)
781285
public function all(array $params = array())
    {
        $endpoint = '/admin/comments.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createCollection(Comment::class, $response['comments']);
    }
1175353
def obtain_comments(check = nil)

      if check.blank? && !@content.blank? && @content[0].blank?
        Comment.where(:post_id => @content.id, :comment_approved => 'Y')
      else
        Comment.where(:post_id => check, :comment_approved => 'Y')
      end

    end
838490
def comments_for(context, obj):
    
    form_class = import_dotted_path(settings.COMMENT_FORM_CLASS)
    form = form_class(context["request"], obj)
    context_form = context.get("posted_comment_form", form)
    context.update({
        'posted_comment_form':
            context_form if context_form.target_object == obj else form,
        'unposted_comment_form': form,
        'comment_url': reverse("comment"),
        'object_for_comments': obj,
    })
    return context
195076
public function massUpdate(CommentsRequest $request)
    {
        $this->authorize('otherUpdate', $this->model);

        $comments = $this->model->whereIn('id', $request->comments);
        $messages = [];

        switch ($request->mass_action) {
            case 'published':
                if (! $comments->update(['is_approved' => true])) {
                    $messages[] = 'unable to published';
                }
                break;
            case 'unpublished':
                if (! $comments->update(['is_approved' => false])) {
                    $messages[] = 'unable to unpublished';
                }
                break;
            case 'delete':
                if (! $comments->get()->each->delete()) {
                    $messages[] = 'unable to delete';
                }
                break;
        }

        $message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';

        return $this->makeRedirect(true, 'admin.comments.index', $message);
    }
822734
def check_user_can_view_comments(user_info, recid):
    
    # Check user can view the record itself first
    (auth_code, auth_msg) = check_user_can_view_record(user_info, recid)
    if auth_code:
        return (auth_code, auth_msg)

    # Check if user can view the comments
    # But first can we find an authorization for this case action,
    # for this collection?
    record_primary_collection = guess_primary_collection_of_a_record(recid)
    return acc_authorize_action(
        user_info,
        'viewcomment',
        authorized_if_no_roles=True,
        collection=record_primary_collection)
878425
public function get_comments( $count = null, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'Timber\Comment' ) {
		return $this->comments($count, $order, $type, $status, $CommentClass);
	}
558533
public function getComment() : ?string 
    {
        if ( ! $this->hasComment()) {
            $this->setComment($this->getDefaultComment());
        }
        return $this->comment;
    }
167253
public function accessTokens()
    {
        if (is_null($this->accessTokenRequests)) {
            $this->accessTokenRequests = new AccessTokenRequest($this->client);
        }

        return $this->accessTokenRequests;
    }
1112197
public function getComment()
    {
        if ($this->comment === null) {
            $match = [];
            preg_match(self::$REGEX_COMMENT, $this->output, $match);
            $this->comment = array_key_exists(2, $match) ? trim($match[2]) : '';
        }

        return $this->comment;
    }