You are here

public function FontAwesome::getIconElement in Social Media Links Block and Field 8.2

Get the iconset element.

Parameters

string $platform: The platform id.

string $style: The style.

Return value

array The array with the icon element.

Overrides IconsetBase::getIconElement

File

src/Plugin/SocialMediaLinks/Iconset/FontAwesome.php, line 46

Class

FontAwesome
Provides 'elegantthemes' iconset.

Namespace

Drupal\social_media_links\Plugin\SocialMediaLinks\Iconset

Code

public function getIconElement($platform, $style) {
  $icon_name = $platform
    ->getIconName();
  switch ($icon_name) {
    case 'vimeo':
      $icon_name = $icon_name . '-square';
      break;
    case 'googleplus':
      $icon_name = 'google-plus';
      break;
    case 'email':
      $icon_name = 'envelope';
      break;
    case 'website':
      $icon_name = 'home';
      break;
  }
  if ($icon_name == 'envelope' || $icon_name == 'home' || $icon_name == 'rss') {
    $icon = [
      '#type' => 'markup',
      '#markup' => "<span class='fa fa-{$icon_name} fa-{$style}'></span>",
    ];
  }
  else {
    $icon = [
      '#type' => 'markup',
      '#markup' => "<span class='fab fa-{$icon_name} fa-{$style}'></span>",
    ];
  }
  return $icon;
}