You are here

public function TwitterWidget::getWidget in Twitter Embed 8

Returns a Twitter widget depending on the configuration.

Parameters

array $configuration: List of selected configuration.

Return value

array The Twitter widget as a render array.

Overrides TwitterWidgetInterface::getWidget

File

src/TwitterWidget.php, line 58

Class

TwitterWidget
Class TwitterWidget.

Namespace

Drupal\twitter_embed

Code

public function getWidget(array $configuration) {
  $build['twitter_widget'] = [
    '#type' => 'link',
    '#title' => $this
      ->createLabel($configuration),
    '#url' => $this
      ->createUrl($configuration),
    '#attributes' => $this
      ->createAttributes($configuration),
    '#attached' => [
      'library' => [
        'twitter_embed/twitter_widgets',
      ],
    ],
  ];
  return $build;
}