function IconPackManager::processDefinition
Overrides DefaultPluginManager::processDefinition
File
-
core/
lib/ Drupal/ Core/ Theme/ Icon/ Plugin/ IconPackManager.php, line 208
Class
- IconPackManager
- Defines an icon pack plugin manager to deal with icons.
Namespace
Drupal\Core\Theme\Icon\PluginCode
public function processDefinition(&$definition, $plugin_id) : void {
if (preg_match('@[^a-z0-9_]@', $plugin_id)) {
throw new IconPackConfigErrorException(sprintf('Invalid icon pack id in: %s, name: %s must contain only lowercase letters, numbers, and underscores.', $definition['provider'], $plugin_id));
}
$this->validateDefinition($definition);
// Do not include disabled definition with `enabled: false`.
if (!($definition['enabled'] ?? TRUE)) {
return;
}
if (!isset($definition['provider'])) {
return;
}
// Provide path information for extractors.
$relative_path = $this->moduleHandler
->moduleExists($definition['provider']) ? $this->moduleHandler
->getModule($definition['provider'])
->getPath() : $this->themeHandler
->getTheme($definition['provider'])
->getPath();
$definition['relative_path'] = $relative_path;
// To avoid the need for appRoot in extractors.
$definition['absolute_path'] = sprintf('%s/%s', $this->appRoot, $relative_path);
// Load all discovered icon ids in the definition so they are cached.
$definition['icons'] = $this->getIconsFromDefinition($definition);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.