Contao\ArticleModel::findPublishedById PHP Method

findPublishedById() public static method

Find a published article by its ID
public static findPublishedById ( integer $intId, array $arrOptions = [] ) : ArticleModel | null
$intId integer The article ID
$arrOptions array An optional options array
return ArticleModel | null The model or null if there is no published article
    public static function findPublishedById($intId, array $arrOptions = array())
    {
        $t = static::$strTable;
        $arrColumns = array("{$t}.id=?");
        if (isset($arrOptions['ignoreFePreview']) || !BE_USER_LOGGED_IN) {
            $time = \Date::floorToMinute();
            $arrColumns[] = "({$t}.start='' OR {$t}.start<='{$time}') AND ({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "') AND {$t}.published='1'";
        }
        return static::findOneBy($arrColumns, $intId, $arrOptions);
    }