original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Get the comments associated to a translatable strings.
  
  @param LocaleEntity $locale
  @param TranslatableEntity $translatable
docstring_tokens: Get the comments associated to a translatable strings .