original_string: public static function findPublishedByNews($newsId)
      {
          if (0 === \count($ids = Model::getRelatedValues('tl_news', 'categories', $newsId))) {
              return null;
          }
  
          $t = static::getTableAlias();
          $columns = ["$t.id IN (".\implode(',', \array_map('intval', \array_unique($ids))).')'];
          $values = [];
  
          if (!BE_USER_LOGGED_IN) {
              $columns[] = "$t.published=?";
              $values[] = 1;
          }
  
          return static::findBy($columns, $values, ['order' => "$t.sorting"]);
      }
code: public static function findPublishedByNews($newsId)
      {
          if (0 === \count($ids = Model::getRelatedValues('tl_news', 'categories', $newsId))) {
              return null;
          }
  
          $t = static::getTableAlias();
          $columns = ["$t.id IN (".\implode(',', \array_map('intval', \array_unique($ids))).')'];
          $values = [];
  
          if (!BE_USER_LOGGED_IN) {
              $columns[] = "$t.published=?";
              $values[] = 1;
          }
  
          return static::findBy($columns, $values, ['order' => "$t.sorting"]);
      }
code_tokens: public static function findPublishedByNews ( $ newsId ) { if ( 0 === \ count ( $ ids = Model :: getRelatedValues ( 'tl_news' , 'categories' , $ newsId ) ) ) { return null ; } $ t = static :: getTableAlias ( ) ; $ columns = [ "$t.id IN (" . \ implode ( ',' , \ array_map ( 'intval' , \ array_unique ( $ ids ) ) ) . ')' ] ; $ values = [ ] ; if ( ! BE_USER_LOGGED_IN ) { $ columns [ ] = "$t.published=?" ; $ values [ ] = 1 ; } return static :: findBy ( $ columns , $ values , [ 'order' => "$t.sorting" ] ) ; }
docstring: Find the published categories by news.
  
  @param int|array $newsId
  
  @return Collection|null
docstring_tokens: Find the published categories by news .