You are here

class FontAwesome in Social Media Links Block and Field 8.2

Provides 'elegantthemes' iconset.

Plugin annotation


@Iconset(
  id = "fontawesome",
  publisher = "Font Awesome",
  publisherUrl = "http://fontawesome.github.io/",
  downloadUrl = "http://fortawesome.github.io/Font-Awesome/",
  name = "Font Awesome",
)

Hierarchy

Expanded class hierarchy of FontAwesome

File

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

Namespace

Drupal\social_media_links\Plugin\SocialMediaLinks\Iconset
View source
class FontAwesome extends IconsetBase implements IconsetInterface {

  /**
   * {@inheritdoc}
   */
  public function setPath($iconset_id) {
    $this->path = $this->finder
      ->getPath($iconset_id) ? $this->finder
      ->getPath($iconset_id) : 'library';
  }

  /**
   * {@inheritdoc}
   */
  public function getStyle() {
    return [
      '2x' => 'fa-2x',
      '3x' => 'fa-3x',
      '4x' => 'fa-4x',
      '5x' => 'fa-5x',
      'in' => 'fa-in',
      'lg' => 'fa-lg',
      'fw' => 'fa-fw',
    ];
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function getLibrary() {
    if (\Drupal::service('module_handler')
      ->moduleExists('fontawesome')) {
      return parent::getLibrary();
    }
    else {
      return [
        'social_media_links/fontawesome.component',
      ];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getIconPath($icon_name, $style) {
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FontAwesome::getIconElement public function Get the iconset element. Overrides IconsetBase::getIconElement
FontAwesome::getIconPath public function Return the path of an icon for the given platform (iconName) and style. Overrides IconsetInterface::getIconPath
FontAwesome::getLibrary public function Get the library. Overrides IconsetBase::getLibrary
FontAwesome::getStyle public function Return the available styles. Overrides IconsetInterface::getStyle
FontAwesome::setPath public function Set the path for the given iconset. Overrides IconsetBase::setPath
IconsetBase::$finder protected property
IconsetBase::$path protected property
IconsetBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
IconsetBase::explodeStyle public static function Explode the styles.
IconsetBase::getDownloadUrl public function Return the url to download the iconset. Overrides IconsetInterface::getDownloadUrl
IconsetBase::getName public function Return the name of the iconset. Overrides IconsetInterface::getName
IconsetBase::getPath public function Get the path to the iconset.
IconsetBase::getPublisher public function Return the name of the publisher. Overrides IconsetInterface::getPublisher
IconsetBase::getPublisherUrl public function Return the url of the publisher. Overrides IconsetInterface::getPublisherUrl
IconsetBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.