function IconDefinition::create
Overrides IconDefinitionInterface::create
1 call to IconDefinition::create()
- IconExtractorBase::createIcon in core/
lib/ Drupal/ Core/ Theme/ Icon/ IconExtractorBase.php - Create the icon definition from an extractor plugin.
File
-
core/
lib/ Drupal/ Core/ Theme/ Icon/ IconDefinition.php, line 49
Class
- IconDefinition
- Handle an icon definition.
Namespace
Drupal\Core\Theme\IconCode
public static function create(string $pack_id, string $icon_id, string $template, ?string $source = NULL, ?string $group = NULL, array $data = []) : self {
$errors = [];
if (0 === strlen($pack_id)) {
$errors[] = 'Empty pack_id provided!';
}
if (0 === strlen($icon_id)) {
$errors[] = 'Empty icon_id provided!';
}
if (0 === strlen($template)) {
$errors[] = 'Empty template provided!';
}
if (count($errors)) {
throw new IconDefinitionInvalidDataException(implode(' ', $errors));
}
// Cleanup of data that do not need to be passed.
unset($data['config']['sources'], $data['relative_path'], $data['absolute_path']);
return new self($pack_id, $icon_id, $template, $source, $group, $data);
}