private function fetchNews($hostname)
    {
        $source = $this->getOption('general/branding/news_source', 'https://news.bolt.cm/');
        $options = $this->fetchNewsOptions($hostname);

        $this->app['logger.system']->info('Fetching from remote server: ' . $source, ['event' => 'news']);

        try {
            $fetchedNewsData = (string) $this->app['guzzle.client']->get($source, $options)->getBody();
        } catch (RequestException $e) {
            $this->app['logger.system']->error(
                'Error occurred during newsfeed fetch',
                ['event' => 'exception', 'exception' => $e]
            );

            return [
                'error' => [
                    'type'   => 'error',
                    'title'  => 'Unable to fetch news!',
                    'teaser' => "<p>Unable to connect to $source</p>",
                ],
            ];
        }

        try {
            $fetchedNewsItems = Json::parse($fetchedNewsData);
        } catch (ParseException $e) {
            // Just move on, a user-friendly notice is returned below.
            $fetchedNewsItems = [];
        }

        $newsVariable = $this->getOption('general/branding/news_variable');
        if ($newsVariable && array_key_exists($newsVariable, $fetchedNewsItems)) {
            $fetchedNewsItems = $fetchedNewsItems[$newsVariable];
        }

        $news = [];

        // Iterate over the items, pick the first news-item that
        // applies and the first alert we need to show
        foreach ($fetchedNewsItems as $item) {
            $type = isset($item->type) ? $item->type : 'information';
            if (!isset($news[$type])
                && (empty($item->target_version) || Bolt\Version::compare($item->target_version, '>'))
            ) {
                $news[$type] = $item;
            }
        }

        if ($news) {
            return $news;
        }
        $this->app['logger.system']->error('Invalid JSON feed returned', ['event' => 'news']);

        return [
            'error' => [
                'type'   => 'error',
                'title'  => 'Unable to fetch news!',
                'teaser' => "<p>Invalid JSON feed returned by $source</p>",
            ],
        ];
    }
private function fetchNews($hostname)
    {
        $source = $this->getOption('general/branding/news_source', 'https://news.bolt.cm/');
        $options = $this->fetchNewsOptions($hostname);

        $this->app['logger.system']->info('Fetching from remote server: ' . $source, ['event' => 'news']);

        try {
            $fetchedNewsData = (string) $this->app['guzzle.client']->get($source, $options)->getBody();
        } catch (RequestException $e) {
            $this->app['logger.system']->error(
                'Error occurred during newsfeed fetch',
                ['event' => 'exception', 'exception' => $e]
            );

            return [
                'error' => [
                    'type'   => 'error',
                    'title'  => 'Unable to fetch news!',
                    'teaser' => "<p>Unable to connect to $source</p>",
                ],
            ];
        }

        try {
            $fetchedNewsItems = Json::parse($fetchedNewsData);
        } catch (ParseException $e) {
            // Just move on, a user-friendly notice is returned below.
            $fetchedNewsItems = [];
        }

        $newsVariable = $this->getOption('general/branding/news_variable');
        if ($newsVariable && array_key_exists($newsVariable, $fetchedNewsItems)) {
            $fetchedNewsItems = $fetchedNewsItems[$newsVariable];
        }

        $news = [];

        // Iterate over the items, pick the first news-item that
        // applies and the first alert we need to show
        foreach ($fetchedNewsItems as $item) {
            $type = isset($item->type) ? $item->type : 'information';
            if (!isset($news[$type])
                && (empty($item->target_version) || Bolt\Version::compare($item->target_version, '>'))
            ) {
                $news[$type] = $item;
            }
        }

        if ($news) {
            return $news;
        }
        $this->app['logger.system']->error('Invalid JSON feed returned', ['event' => 'news']);

        return [
            'error' => [
                'type'   => 'error',
                'title'  => 'Unable to fetch news!',
                'teaser' => "<p>Invalid JSON feed returned by $source</p>",
            ],
        ];
    }
private function fetchNews ( $ hostname ) { $ source = $ this -> getOption ( 'general/branding/news_source' , 'https://news.bolt.cm/' ) ; $ options = $ this -> fetchNewsOptions ( $ hostname ) ; $ this -> app [ 'logger.system' ] -> info ( 'Fetching from remote server: ' . $ source , [ 'event' => 'news' ] ) ; try { $ fetchedNewsData = ( string ) $ this -> app [ 'guzzle.client' ] -> get ( $ source , $ options ) -> getBody ( ) ; } catch ( RequestException $ e ) { $ this -> app [ 'logger.system' ] -> error ( 'Error occurred during newsfeed fetch' , [ 'event' => 'exception' , 'exception' => $ e ] ) ; return [ 'error' => [ 'type' => 'error' , 'title' => 'Unable to fetch news!' , 'teaser' => "<p>Unable to connect to $source</p>" , ] , ] ; } try { $ fetchedNewsItems = Json :: parse ( $ fetchedNewsData ) ; } catch ( ParseException $ e ) { // Just move on, a user-friendly notice is returned below. $ fetchedNewsItems = [ ] ; } $ newsVariable = $ this -> getOption ( 'general/branding/news_variable' ) ; if ( $ newsVariable && array_key_exists ( $ newsVariable , $ fetchedNewsItems ) ) { $ fetchedNewsItems = $ fetchedNewsItems [ $ newsVariable ] ; } $ news = [ ] ; // Iterate over the items, pick the first news-item that // applies and the first alert we need to show foreach ( $ fetchedNewsItems as $ item ) { $ type = isset ( $ item -> type ) ? $ item -> type : 'information' ; if ( ! isset ( $ news [ $ type ] ) && ( empty ( $ item -> target_version ) || Bolt \ Version :: compare ( $ item -> target_version , '>' ) ) ) { $ news [ $ type ] = $ item ; } } if ( $ news ) { return $ news ; } $ this -> app [ 'logger.system' ] -> error ( 'Invalid JSON feed returned' , [ 'event' => 'news' ] ) ; return [ 'error' => [ 'type' => 'error' , 'title' => 'Unable to fetch news!' , 'teaser' => "<p>Invalid JSON feed returned by $source</p>" , ] , ] ; }
Get the news from Bolt HQ.

@param string $hostname

@return array
Get the news from Bolt HQ .