abstract class IconsetBase in Social Media Links Block and Field 8.2
Base class for iconset.
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\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of IconsetBase
5 files declare their use of IconsetBase
- ElegantThemes.php in src/
Plugin/ SocialMediaLinks/ Iconset/ ElegantThemes.php - FontAwesome.php in src/
Plugin/ SocialMediaLinks/ Iconset/ FontAwesome.php - Nouveller.php in src/
Plugin/ SocialMediaLinks/ Iconset/ Nouveller.php - SocialMediaLinksBlock.php in src/
Plugin/ Block/ SocialMediaLinksBlock.php - SocialMediaLinksFieldDefaultFormatter.php in modules/
social_media_links_field/ src/ Plugin/ Field/ FieldFormatter/ SocialMediaLinksFieldDefaultFormatter.php
File
- src/
IconsetBase.php, line 12
Namespace
Drupal\social_media_linksView source
abstract class IconsetBase extends PluginBase implements IconsetInterface, ContainerFactoryPluginInterface {
/**
* {@inheritdoc}
*/
protected $path = '';
/**
* {@inheritdoc}
*/
protected $finder;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, IconsetFinderService $finder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->finder = $finder;
$this
->setPath($plugin_id);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('social_media_links.finder'));
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->pluginDefinition['name'];
}
/**
* {@inheritdoc}
*/
public function getPublisher() {
return $this->pluginDefinition['publisher'];
}
/**
* {@inheritdoc}
*/
public function getPublisherUrl() {
return $this->pluginDefinition['publisherUrl'];
}
/**
* {@inheritdoc}
*/
public function getDownloadUrl() {
return $this->pluginDefinition['downloadUrl'];
}
/**
* Get the path to the iconset.
*
* @return string
* The path.
*/
public function getPath() {
return $this->path;
}
/**
* Set the path for the given iconset.
*
* @param string $iconset_id
* The id of the iconset.
*/
public function setPath($iconset_id) {
$this->path = $this->finder
->getPath($iconset_id);
}
/**
* Get the library.
*
* This method is used if the iconset should be used via the Library API.
*
* @return array
* The library.
*/
public function getLibrary() {
return NULL;
}
/**
* Get the iconset element.
*
* @param string $platform
* The platform id.
* @param string $style
* The style.
*
* @return array
* The array with the icon element.
*/
public function getIconElement($platform, $style) {
$iconName = $platform
->getIconName();
$path = $this
->getIconPath($iconName, $style);
$icon = [
'#theme' => 'image',
'#uri' => $path,
];
return $icon;
}
/**
* Explode the styles.
*
* @param string $style
* The styles.
* @param bool $key
* If TRUE: Only the given key is returned.
*
* @return string|array
* The array with the styles or a string if a $key was given.
*/
public static function explodeStyle($style, $key = FALSE) {
$exploded = explode(':', $style);
if ($key) {
return $exploded[$key];
}
return [
'iconset' => isset($exploded[0]) ? $exploded[0] : '',
'style' => isset($exploded[1]) ? $exploded[1] : '',
];
}
}
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 | |
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 | Get the iconset element. | 1 |
IconsetBase:: |
public | function | Get the library. | 1 |
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 | Set the path for the given iconset. | 1 |
IconsetBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
IconsetInterface:: |
public | function | Return the path of an icon for the given platform (iconName) and style. | 3 |
IconsetInterface:: |
public | function | Return the available styles. | 3 |
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. |