function IconDefinition::create
Overrides IconDefinitionInterface::create
7 calls to IconDefinition::create()
- ExtractorTest::testCreateIcon in core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ Plugin/ ExtractorTest.php - Test the IconExtractorBase:createIcon method.
- IconDefinitionTest::testCreateIcon in core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ IconDefinitionTest.php - Test the IconDefinition::createIcon method.
- IconDefinitionTest::testCreateIconError in core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ IconDefinitionTest.php - Test the IconDefinition::create method with errors.
- IconDefinitionTest::testCreateIconHumanize in core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ IconDefinitionTest.php - Test the IconDefinition::humanize method.
- IconDefinitionTest::testGetRenderable in core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ IconDefinitionTest.php - Test the IconDefinition::getRenderable method.
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.