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"]);
    }
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"]);
    }
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" ] ) ; }
Find the published categories by news.

@param int|array $newsId

@return Collection|null
Find the published categories by news .