1 block.news.inc public static DashboardNewsBlock::refreshNewsFeed()

Fetch news from the news source and set the cache for future responses.

Return value

FALSE|array:

File

core/modules/dashboard/includes/block.news.inc, line 111
Dashboard block displaying BackdropCMS.org news items.

Class

DashboardNewsBlock

Code

public static function refreshNewsFeed() {
  $news = FALSE;
  $feed_url = config_get('dashboard.settings', 'news_feed_url');

  // A short timeout means that we won't delay loading the dashboard if the
  // cache is cleared and no network is available.
  if ($feed_url) {
    $feed = backdrop_http_request($feed_url, array(
      'timeout' => 2,
    ));
    if ($feed->code === '200') {
      $news = json_decode($feed->data, TRUE);
    }
  }

  // Cache for one week, though the feed will be updated more frequently by
  // dashboard_cron().
  cache()->set('dashboard_news_feed', $news, REQUEST_TIME + 604800);

  return $news;
}