You are here

private function FacebookFeedBlock::themePost in Facebook Feed Block 8

Creates a themable array of post data.

Parameters

array $post: Object containing post data from a call to Facebook's Graph API.

Return value

array A renderable array.

1 call to FacebookFeedBlock::themePost()
FacebookFeedBlock::build in src/Plugin/Block/FacebookFeedBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/FacebookFeedBlock.php, line 224

Class

FacebookFeedBlock
Provides a 'FacebookFeedBlock' block.

Namespace

Drupal\facebook_feed\Plugin\Block

Code

private function themePost(array $post) {
  return [
    '#theme' => 'facebook_post',
    '#id' => $post['id'] ?: '',
    '#created_time' => $post['created_time'] ?: '',
    '#message' => $post['message'] ?: '',
    '#picture' => $post['picture'] ?: '',
    '#link' => $post['link'] ?: '',
    '#show_socials' => $this->configuration['show_socials'],
    '#num_likes' => \array_key_exists('likes', $post) ? $post['likes']['summary']['total_count'] : 0,
    '#num_comments' => \array_key_exists('comments', $post) ? $post['comments']['summary']['total_count'] : 0,
    '#num_reactions' => \array_key_exists('reactions', $post) ? $post['reactions']['summary']['total_count'] : 0,
    '#num_shares' => \array_key_exists('shares', $post) ? $post['shares']['count'] : 0,
  ];
}