Newscoop\Services\CommentService::getAllReplies PHP Метод

getAllReplies() публичный Метод

Gets all replies to a comment.
public getAllReplies ( integer | array $commentId, Newscoop\Repository\CommentRepository $commentRepository ) : array
$commentId integer | array Comment id
$commentRepository Newscoop\Repository\CommentRepository Comment repository
Результат array
    public function getAllReplies($commentId, $commentRepository)
    {
        if (!is_array($commentId)) {
            $directReplies = $commentRepository->getDirectReplies($commentId);
            if (count($directReplies)) {
                return array_merge(array($commentId), $this->getAllReplies($directReplies, $commentRepository));
            } else {
                return array($commentId);
            }
        } else {
            if (count($commentId) > 1) {
                return array_merge($this->getAllReplies(array_pop($commentId), $commentRepository), $this->getAllReplies($commentId, $commentRepository));
            } else {
                return $this->getAllReplies(array_pop($commentId), $commentRepository);
            }
        }
    }