Commit cba29a7c authored by Matthieu Scarset's avatar Matthieu Scarset
Browse files

Issue #3125828: Add a theme function, template for Tweets markup

parent 12d787c8
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -333,10 +333,12 @@ class TwitterBlockBase extends BlockBase implements ContainerFactoryPluginInterf
   * Render Tweets.
   */
  public function displayTweets(array $embed) {
    $build = [];
    foreach ($embed as $tweet) {
      $build[] = ['#markup' => $tweet['html']];
    }

    $build[] = [
      '#theme' => 'twitter_api_block_tweets',
      '#embeds' => $embed
    ];

    return $build;
  }

+14 −0
Original line number Diff line number Diff line
{#
/**
 * @file
 * Default theme implementation for the Twitter API display tweets method.
 *
 * Available variables:
 * - embeds: An array of embeds.
 *
 * @ingroup themeable
 */
#}
{% for item in embeds %}
  {{ item.html|raw }}
{% endfor %}
+19 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Contains hook implementations for twitter_api_block.
 */

/**
 * Implements hook_theme().
 */
function twitter_api_block_theme() {
  return [
    'twitter_api_block_tweets' => [
      'variables' => [
        'embeds' => NULL,
      ],
    ],
  ];
}