private function TwitterWidget::createAttributes in Twitter Embed 8
Returns attributes depending on the configuration.
Parameters
array $configuration: List of selected configuration.
Return value
array List of attributes.
1 call to TwitterWidget::createAttributes()
- TwitterWidget::getWidget in src/
TwitterWidget.php - Returns a Twitter widget depending on the configuration.
File
- src/
TwitterWidget.php, line 123
Class
- TwitterWidget
- Class TwitterWidget.
Namespace
Drupal\twitter_embedCode
private function createAttributes(array $configuration) {
$result = [];
// Common data-attributes.
// @todo review common data-attributes and polymorphism for differences.
$result['class'] = [
'twitter-' . $configuration['display_style'],
];
if (!empty($configuration['language'])) {
$result['lang'] = $configuration['language'];
}
// @todo complete data-attribute list and check conditions depending on the type
// Timeline specific data-attributes
if (!empty($configuration['theme'])) {
$result['data-theme'] = $configuration['theme'];
}
if (!empty($configuration['chrome'])) {
$options = array_keys(array_filter($configuration['chrome']));
if (count($options)) {
$result['data-chrome'] = implode(' ', $options);
}
}
if (!empty($configuration['width'])) {
$result['data-width'] = $configuration['width'];
}
if (!empty($configuration['height'])) {
$result['data-height'] = $configuration['height'];
}
if (!empty($configuration['link_color'])) {
$result['data-link-color'] = $configuration['link_color'];
}
if (!empty($configuration['border_color'])) {
$result['data-border-color'] = $configuration['border_color'];
}
if (!empty($configuration['tweet_limit'])) {
$result['data-tweet-limit'] = $configuration['tweet_limit'];
}
if (!empty($configuration['aria_polite'])) {
$result['aria-polite'] = $configuration['aria_polite'];
}
// Button specific data-attributes.
if ($configuration['hide_username']) {
$result['data-show-screen-name'] = 'false';
}
if ($configuration['hide_followers_count']) {
$result['data-show-count'] = 'false';
}
if (!empty($configuration['size'])) {
$result['data-size'] = 'large';
}
return $result;
}