class IconExtractorBase
Base class for icon extractor plugins.
@internal This API is experimental.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Theme\Icon\IconExtractorBase extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Core\Theme\Icon\IconExtractorInterface, \Drupal\Core\Plugin\PluginWithFormsInterface uses \Drupal\Core\Plugin\PluginWithFormsTrait
Expanded class hierarchy of IconExtractorBase
1 file declares its use of IconExtractorBase
- TestExtractor.php in core/
modules/ system/ tests/ modules/ icon_test/ src/ Plugin/ IconExtractor/ TestExtractor.php
File
-
core/
lib/ Drupal/ Core/ Theme/ Icon/ IconExtractorBase.php, line 19
Namespace
Drupal\Core\Theme\IconView source
abstract class IconExtractorBase extends PluginBase implements IconExtractorInterface, PluginWithFormsInterface {
use PluginWithFormsTrait;
// Remove internal values and allow extractor to add any needed values.
private const DEFINITION_REMOVE = [
'enabled',
'template',
'description',
'links',
'config',
];
/**
* {@inheritdoc}
*/
public function label() : string {
return (string) $this->pluginDefinition['label'];
}
/**
* {@inheritdoc}
*/
public function description() : string {
return (string) $this->pluginDefinition['description'];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) : array {
if (!isset($this->configuration['settings'])) {
return $form;
}
return IconExtractorSettingsForm::generateSettingsForm($this->configuration['settings'], $form_state);
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) : void {
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) : void {
}
/**
* {@inheritdoc}
*/
public function loadIcon(array $icon_data) : ?IconDefinitionInterface {
if (!isset($icon_data['icon_id']) || empty($icon_data['icon_id'])) {
return NULL;
}
return $this->createIcon($icon_data['icon_id'], $icon_data['source'] ?? '', $icon_data['group'] ?? NULL);
}
/**
* {@inheritdoc}
*/
public function createIcon(string $icon_id, ?string $source = NULL, ?string $group = NULL, ?array $data = NULL) : IconDefinitionInterface {
if (!isset($this->configuration['template'])) {
throw new IconPackConfigErrorException(sprintf('Missing `template` in your definition, extractor %s requires this value.', $this->getPluginId()));
}
// Clean unused pack definition values as they will be passed to the context
// of the Twig.
$data_definition = array_diff_key($this->configuration, array_flip(self::DEFINITION_REMOVE));
return IconDefinition::create($this->configuration['id'], $icon_id, $this->configuration['template'], $source, $group, $data ? array_merge($data, $data_definition) : $data_definition);
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
IconExtractorBase::buildConfigurationForm | public | function | Form constructor. | Overrides PluginFormInterface::buildConfigurationForm | ||
IconExtractorBase::createIcon | public | function | Create the icon definition from an extractor plugin. | Overrides IconExtractorInterface::createIcon | ||
IconExtractorBase::DEFINITION_REMOVE | private | constant | ||||
IconExtractorBase::description | public | function | Returns the translated plugin description. | Overrides IconExtractorInterface::description | ||
IconExtractorBase::label | public | function | Returns the translated plugin label. | Overrides IconExtractorInterface::label | ||
IconExtractorBase::loadIcon | public | function | Load an icon object. | Overrides IconExtractorInterface::loadIcon | 1 | |
IconExtractorBase::submitConfigurationForm | public | function | Form submission handler. | Overrides PluginFormInterface::submitConfigurationForm | ||
IconExtractorBase::validateConfigurationForm | public | function | Form validation handler. | Overrides PluginFormInterface::validateConfigurationForm | ||
IconExtractorInterface::discoverIcons | public | function | Get a list of all the icons discovered by this extractor. | 5 | ||
PluginBase::$configuration | protected | property | Configuration information passed into the plugin. | |||
PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. | |||
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 | ||
PluginBase::getPluginId | public | function | Gets the plugin ID of the plugin instance. | Overrides PluginInspectionInterface::getPluginId | ||
PluginBase::isConfigurable | Deprecated | public | function | Determines if the plugin is configurable. | ||
PluginBase::__construct | public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 8 | ||
PluginWithFormsTrait::getFormClass | public | function | Implements \Drupal\Core\Plugin\PluginWithFormsInterface::getFormClass(). | |||
PluginWithFormsTrait::hasFormClass | public | function | Implements \Drupal\Core\Plugin\PluginWithFormsInterface::hasFormClass(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.