CommentList::renderCheckActions PHP Method

renderCheckActions() public method

Note that when it finds an actionable approval code, it performs a redirect back to the same page after completing the action, with ?comment_success=2 on successful action, or ?comment_success=3 on error. It also populates a session variable 'CommentApprovalMessage' with a text message of what occurred.
public renderCheckActions ( ) : string
return string
    public function renderCheckActions()
    {
        $action = $this->wire('input')->get('comment_success');
        if (empty($action) || $action === "1") {
            return '';
        }
        if ($action === '2' || $action === '3') {
            $message = $this->wire('session')->get('CommentApprovalMessage');
            if ($message) {
                $this->wire('session')->remove('CommentApprovalMessage');
                $class = $action === '2' ? 'success' : 'error';
                $commentID = (int) $this->wire('input')->get('comment_id');
                $message = $this->wire('sanitizer')->entities($message);
                if ($commentID) {
                    $message = str_replace($commentID, "<a href='#Comment{$commentID}'>{$commentID}</a>", $message);
                }
                return "<p id='CommentApprovalMessage' class='{$class}'><strong>{$message}</strong></p>";
            }
        }
        if (!$this->field) {
            return '';
        }
        require_once dirname(__FILE__) . '/CommentNotifications.php';
        $no = new CommentNotifications($this->page, $this->field);
        $info = $no->checkActions();
        if ($info['valid']) {
            $url = $this->page->url . '?';
            if ($info['commentID']) {
                $url .= "comment_id={$info['commentID']}&";
            }
            $url .= "comment_success=" . ($info['success'] ? '2' : '3');
            $this->wire('session')->set('CommentApprovalMessage', $info['message']);
            $this->wire('session')->redirect($url . '#CommentApprovalMessage');
        }
        return '';
    }