public function getComments($blogId, $postId, $userId, $filters, $allowedToSeeOnly)
    {
        if (!isset($filters['hiddenFilters'])) {
            $filters['hiddenFilters'] = [];
        }
        //filter on current blog and post
        $filters['hiddenFilters'] = [
            'blog' => $blogId,
            'post' => $postId,
        ];

        //allow to see only published post, or post whose current user is the author
        if ($allowedToSeeOnly) {
            //anonymous only sees published
            if (null === $userId) {
                $options = [
                    'publishedOnly' => true,
                ];
            } else {
                $options = [
                    'allowedToSeeForUser' => $userId,
                ];
            }

            $filters['hiddenFilters'] = array_merge(
                $filters['hiddenFilters'],
                $options);
        }

        return $this->finder->search('Icap\BlogBundle\Entity\Comment', $filters);
    }
public function getComments($blogId, $postId, $userId, $filters, $allowedToSeeOnly)
    {
        if (!isset($filters['hiddenFilters'])) {
            $filters['hiddenFilters'] = [];
        }
        //filter on current blog and post
        $filters['hiddenFilters'] = [
            'blog' => $blogId,
            'post' => $postId,
        ];

        //allow to see only published post, or post whose current user is the author
        if ($allowedToSeeOnly) {
            //anonymous only sees published
            if (null === $userId) {
                $options = [
                    'publishedOnly' => true,
                ];
            } else {
                $options = [
                    'allowedToSeeForUser' => $userId,
                ];
            }

            $filters['hiddenFilters'] = array_merge(
                $filters['hiddenFilters'],
                $options);
        }

        return $this->finder->search('Icap\BlogBundle\Entity\Comment', $filters);
    }
public function getComments ( $ blogId , $ postId , $ userId , $ filters , $ allowedToSeeOnly ) { if ( ! isset ( $ filters [ 'hiddenFilters' ] ) ) { $ filters [ 'hiddenFilters' ] = [ ] ; } //filter on current blog and post $ filters [ 'hiddenFilters' ] = [ 'blog' => $ blogId , 'post' => $ postId , ] ; //allow to see only published post, or post whose current user is the author if ( $ allowedToSeeOnly ) { //anonymous only sees published if ( null === $ userId ) { $ options = [ 'publishedOnly' => true , ] ; } else { $ options = [ 'allowedToSeeForUser' => $ userId , ] ; } $ filters [ 'hiddenFilters' ] = array_merge ( $ filters [ 'hiddenFilters' ] , $ options ) ; } return $ this -> finder -> search ( 'Icap\BlogBundle\Entity\Comment' , $ filters ) ; }
Get comments.

@param $blogId
@param $postId
@param $userId
@param $filters
@param $allowedToSeeOnly
Get comments .