Skip to content

IconSet ​

Type
Abstract Class
Namespace
craft\icons
Inherits
craft\icons\IconSet » yii\base\BaseObject
Implements
yii\base\Configurable
Extended by
craft\icons\DirectoryIconSet
Since
5.12.0

IconSet is the base class for custom icon sets, which can be registered via craft\services\Icons::EVENT_REGISTER_ICON_SETS.

Icons selected from a custom icon set are stored as set-handle:icon-name.

View source

Public Properties ​

PropertyDescription
handlestring – The icon set’s handle, which prefixes the stored values of icons selected from it.
iconsstring[]
namestring – The icon set’s name, as it should be shown in the control panel.

handle ​

Type
string
Default value
null

The icon set’s handle, which prefixes the stored values of icons selected from it.

Handles must begin with a letter, and can only contain letters, numbers, underscores, and hyphens.

View source

icons ​

Type
string[]
Default value
null
Access
Read-only

View source

name ​

Type
string
Default value
null

The icon set’s name, as it should be shown in the control panel.

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
getIcons()Returns the names of the icons in the set.
getKeywords()Returns search keywords for an icon, in addition to its name.
getSvg()Returns an icon’s SVG markup, or null if the icon doesn’t exist.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.

getIcons() ​

Returns the names of the icons in the set.

Icon names can’t contain slashes, backslashes, or angle brackets.

View source

Returns ​

string[]

getKeywords() ​

Returns search keywords for an icon, in addition to its name.

View source

Arguments ​

  • $icon (string) – The icon name

Returns ​

string[]

getSvg() ​

Returns an icon’s SVG markup, or null if the icon doesn’t exist.

View source

Arguments ​

  • $icon (string) – The icon name

Returns ​

string, null