public function getComments(LocaleEntity $locale, TranslatableEntity $translatable, TranslatableCommentEntity $parentComment = null)
    {
        $repo = $this->app->make(TranslatableCommentRepository::class);
        if ($parentComment === null) {
            $qb = $repo->createQueryBuilder('c');
            $qb
                ->where('c.translatable = :translatable')
                ->andWhere('c.parentComment is null')
                ->andWhere($qb->expr()->orX(
                    'c.locale = :locale',
                    'c.locale is null'
                ))
                ->orderBy('c.postedOn', 'ASC')
                ->setParameter('translatable', $translatable)
                ->setParameter('locale', $locale)
                ;
            $comments = $qb->getQuery()->getResult();
        } else {
            $comments = $repo->findBy(
                ['parentComment' => $parentComment],
                ['postedOn' => 'ASC']
            );
        }
        $result = [];
        $uh = $this->app->make(UserService::class);
        $dh = $this->app->make('helper/date');
        $me = new \User();
        $myID = $me->isRegistered() ? (int) $me->getUserID() : null;
        foreach ($comments as $comment) {
            $result[] = [
                'id' => $comment->getID(),
                'date' => $dh->formatPrettyDateTime($comment->getPostedOn(), true, true),
                'mine' => $myID && $myID === $comment->getPostedBy(),
                'by' => $uh->format($comment->getPostedBy()),
                'text' => $comment->getText(),
                'comments' => $this->getComments($locale, $translatable, $comment),
                'isGlobal' => $comment->getLocale() === null,
            ];
        }

        return $result;
    }
public function getComments(LocaleEntity $locale, TranslatableEntity $translatable, TranslatableCommentEntity $parentComment = null)
    {
        $repo = $this->app->make(TranslatableCommentRepository::class);
        if ($parentComment === null) {
            $qb = $repo->createQueryBuilder('c');
            $qb
                ->where('c.translatable = :translatable')
                ->andWhere('c.parentComment is null')
                ->andWhere($qb->expr()->orX(
                    'c.locale = :locale',
                    'c.locale is null'
                ))
                ->orderBy('c.postedOn', 'ASC')
                ->setParameter('translatable', $translatable)
                ->setParameter('locale', $locale)
                ;
            $comments = $qb->getQuery()->getResult();
        } else {
            $comments = $repo->findBy(
                ['parentComment' => $parentComment],
                ['postedOn' => 'ASC']
            );
        }
        $result = [];
        $uh = $this->app->make(UserService::class);
        $dh = $this->app->make('helper/date');
        $me = new \User();
        $myID = $me->isRegistered() ? (int) $me->getUserID() : null;
        foreach ($comments as $comment) {
            $result[] = [
                'id' => $comment->getID(),
                'date' => $dh->formatPrettyDateTime($comment->getPostedOn(), true, true),
                'mine' => $myID && $myID === $comment->getPostedBy(),
                'by' => $uh->format($comment->getPostedBy()),
                'text' => $comment->getText(),
                'comments' => $this->getComments($locale, $translatable, $comment),
                'isGlobal' => $comment->getLocale() === null,
            ];
        }

        return $result;
    }
public function getComments ( LocaleEntity $ locale , TranslatableEntity $ translatable , TranslatableCommentEntity $ parentComment = null ) { $ repo = $ this -> app -> make ( TranslatableCommentRepository :: class ) ; if ( $ parentComment === null ) { $ qb = $ repo -> createQueryBuilder ( 'c' ) ; $ qb -> where ( 'c.translatable = :translatable' ) -> andWhere ( 'c.parentComment is null' ) -> andWhere ( $ qb -> expr ( ) -> orX ( 'c.locale = :locale' , 'c.locale is null' ) ) -> orderBy ( 'c.postedOn' , 'ASC' ) -> setParameter ( 'translatable' , $ translatable ) -> setParameter ( 'locale' , $ locale ) ; $ comments = $ qb -> getQuery ( ) -> getResult ( ) ; } else { $ comments = $ repo -> findBy ( [ 'parentComment' => $ parentComment ] , [ 'postedOn' => 'ASC' ] ) ; } $ result = [ ] ; $ uh = $ this -> app -> make ( UserService :: class ) ; $ dh = $ this -> app -> make ( 'helper/date' ) ; $ me = new \ User ( ) ; $ myID = $ me -> isRegistered ( ) ? ( int ) $ me -> getUserID ( ) : null ; foreach ( $ comments as $ comment ) { $ result [ ] = [ 'id' => $ comment -> getID ( ) , 'date' => $ dh -> formatPrettyDateTime ( $ comment -> getPostedOn ( ) , true , true ) , 'mine' => $ myID && $ myID === $ comment -> getPostedBy ( ) , 'by' => $ uh -> format ( $ comment -> getPostedBy ( ) ) , 'text' => $ comment -> getText ( ) , 'comments' => $ this -> getComments ( $ locale , $ translatable , $ comment ) , 'isGlobal' => $ comment -> getLocale ( ) === null , ] ; } return $ result ; }
Get the comments associated to a translatable strings.

@param LocaleEntity $locale
@param TranslatableEntity $translatable
Get the comments associated to a translatable strings .