You are here

protected function TwitterWidgetFormatter::getTweets in Twitter Profile Widget 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/TwitterWidgetFormatter.php \Drupal\twitter_profile_widget\Plugin\Field\FieldFormatter\TwitterWidgetFormatter::getTweets()

Implements hook_preprocess_HOOK().

Take the user-entered Twitter "configuration" and return rendered tweets.

1 call to TwitterWidgetFormatter::getTweets()
TwitterWidgetFormatter::viewElements in src/Plugin/Field/FieldFormatter/TwitterWidgetFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/TwitterWidgetFormatter.php, line 76

Class

TwitterWidgetFormatter
Plugin implementation of the 'twitter_widget' formatter.

Namespace

Drupal\twitter_profile_widget\Plugin\Field\FieldFormatter

Code

protected function getTweets($instance) {
  $tweets = TwitterProfile::pull($instance);

  // If the API call returns errors, do not send any data to the template.
  if ($tweets) {
    return $this
      ->prepareTweets($tweets, $instance['count']);
  }
  return '';
}