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
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\social_media_links\IconsetBase implements ContainerFactoryPluginInterface, IconsetInterface
- class \Drupal\social_media_links\Plugin\SocialMediaLinks\Iconset\FontAwesome implements IconsetInterface
- class \Drupal\social_media_links\IconsetBase implements ContainerFactoryPluginInterface, IconsetInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of FontAwesome
File
- src/
Plugin/ SocialMediaLinks/ Iconset/ FontAwesome.php, line 19
Namespace
Drupal\social_media_links\Plugin\SocialMediaLinks\IconsetView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FontAwesome:: |
public | function |
Get the iconset element. Overrides IconsetBase:: |
|
FontAwesome:: |
public | function |
Return the path of an icon for the given platform (iconName) and style. Overrides IconsetInterface:: |
|
FontAwesome:: |
public | function |
Get the library. Overrides IconsetBase:: |
|
FontAwesome:: |
public | function |
Return the available styles. Overrides IconsetInterface:: |
|
FontAwesome:: |
public | function |
Set the path for the given iconset. Overrides IconsetBase:: |
|
IconsetBase:: |
protected | property | ||
IconsetBase:: |
protected | property | ||
IconsetBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
IconsetBase:: |
public static | function | Explode the styles. | |
IconsetBase:: |
public | function |
Return the url to download the iconset. Overrides IconsetInterface:: |
|
IconsetBase:: |
public | function |
Return the name of the iconset. Overrides IconsetInterface:: |
|
IconsetBase:: |
public | function | Get the path to the iconset. | |
IconsetBase:: |
public | function |
Return the name of the publisher. Overrides IconsetInterface:: |
|
IconsetBase:: |
public | function |
Return the url of the publisher. Overrides IconsetInterface:: |
|
IconsetBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |