Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. IconDefinition.php

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\Icon

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal