Class kartik\icons\Icon
| Inheritance | kartik\icons\Icon |
|---|
Icon is a class for setting up icon frameworks to work with Yii in an easy way To setup a global default icon framework, you can set the Yii param 'icon-framework' to one of the following values in your config file:
- 'bsg' for Bootstrap Glyphicons
- 'fa_' for Font Awesome Icons
- 'el' for Elusive Font Icons
- 'typ' for Typicon Font Icons
- 'whhg' for Web Hosting Hub Glyphs Icons
- 'jui' for JQuery UI Icons
- 'uni' for Unicode Icons
- 'oct' for Github Octicons
- 'si' for Socicon Icons
- 'fi' for FlagIcon Icons
- 'oi' for Open Iconic Icons
- 'icf' for IcoFont Icons
Public Methods
| Method | Description | Defined By |
|---|---|---|
| addFramework() | Add a custom icon set to the icon frameworks | kartik\icons\Icon |
| getFrameworkPrefix() | Returns the prefix for the css framework set (or parses framework setup in Yii parameters) | kartik\icons\Icon |
| map() | Maps the icon framework to the current view. Call this in your view or layout file. | kartik\icons\Icon |
| show() | Displays an icon for a specific framework. | kartik\icons\Icon |
| showLayers() | Displays an icon layer stack as supported by Font Awesome 5 | kartik\icons\Icon |
| showStack() | Displays an icon stack as supported by frameworks like Font Awesome | kartik\icons\Icon |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| getFramework() | Returns the key for css framework set (or parses framework setup in Yii parameters) | kartik\icons\Icon |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| BSG | 'bsg' | kartik\icons\Icon | |
| EL | 'el' | kartik\icons\Icon | |
| FA | 'fa' | kartik\icons\Icon | |
| FAB | 'fab' | kartik\icons\Icon | |
| FAD | 'faD' | kartik\icons\Icon | |
| FAL | 'fal' | kartik\icons\Icon | |
| FAR | 'far' | kartik\icons\Icon | |
| FAS | 'fas' | kartik\icons\Icon | |
| FI | 'fi' | kartik\icons\Icon | |
| FRAMEWORK_INVALID | "Invalid or non-existing framework '{framework}' called in your {method}() method." | kartik\icons\Icon | |
| ICF | 'icf' | kartik\icons\Icon | |
| JUI | 'jui' | kartik\icons\Icon | |
| NS | '\\kartik\\icons\\' | kartik\icons\Icon | |
| OCT | 'oct' | kartik\icons\Icon | |
| OI | 'oi' | kartik\icons\Icon | |
| PARAM_INVALID | "Invalid or non-recognized 'icon-framework' has been setup in Yii params. Check your configuration file." | kartik\icons\Icon | |
| PARAM_NOT_SET | "The 'icon-framework' option has not been setup in Yii params. Check your configuration file." | kartik\icons\Icon | |
| SI | 'si' | kartik\icons\Icon | |
| TYP | 'typ' | kartik\icons\Icon | |
| UNI | 'uni' | kartik\icons\Icon | |
| WHHG | 'whhg' | kartik\icons\Icon |
Method Details
Add a custom icon set to the icon frameworks
| public static void addFramework ( $key, $config ) | ||
| $key | string | The key used to identify the icon set |
| $config | array | The icon configuration |
Returns the key for css framework set (or parses framework setup in Yii parameters)
| protected static string getFramework ( $framework = null, $method = 'show' ) | ||
| $framework | string | The framework to be used with the application |
| $method | string | The method in the Icon class (defaults to |
| throws | yii\base\InvalidConfigException | |
|---|---|---|
Returns the prefix for the css framework set (or parses framework setup in Yii parameters)
| public static string getFrameworkPrefix ( $framework = null, $method = 'show' ) | ||
| $framework | ||
| $method | string | The method in the Icon class (defaults to |
| return | string | The icon framework key |
|---|---|---|
| throws | yii\base\InvalidConfigException | |
Maps the icon framework to the current view. Call this in your view or layout file.
| public static void map ( $view, $framework = null ) | ||
| $view | yii\web\View | The view object |
| $framework | string | The name of the framework, if not passed it will default to the Yii config param 'icon-framework' |
| throws | yii\base\InvalidConfigException | |
|---|---|---|
Displays an icon for a specific framework.
| public static string show ( $name, $options = [], $framework = null, $space = true, $tag = 'i', $fa5 = 'fas' ) | ||
| $name | string | The icon name |
| $options | array | The HTML attributes for the icon. The following special attributes are supported:
|
| $framework | string | Deprecated since v1.4.5 (use/see $options above) |
| $space | boolean | Deprecated since v1.4.5 (use/see $options above) |
| $tag | string | Deprecated since v1.4.5 (use/see $options above) |
| $fa5 | string | Deprecated since v1.4.5 |
| return | string | The HTML formatted icon |
|---|---|---|
| throws | yii\base\InvalidConfigException | |
Displays an icon layer stack as supported by Font Awesome 5
See also https://fontawesome.com/how-to-use/svg-with-js#layering.
| public static string showLayers ( $items = [], $options = [] ) | ||
| $items | array | The icons to be displayed in the layer, each of which is an array consisting of following
configuration e.g.
|
| $options | array | The html attributes for the layers main container. The following special attributes are supported:
|
| return | string | The html formatted icon |
|---|---|---|
| throws | yii\base\InvalidConfigException | |
Displays an icon stack as supported by frameworks like Font Awesome
See also http://fontawesome.io/examples/#stacked.
| public static string showStack ( $name1, $name2, $options = [], $options1 = [], $options2 = [] ) | ||
| $name1 | string | The icon name in stack 1x |
| $name2 | string | The icon name in stack 2x |
| $options | array | The HTML attributes for the icon stack container. The following special attributes are supported:
|
| $options1 | array | The HTML attributes for the icon in stack 1x. The following special attributes are supported:
|
| $options2 | array | The HTML attributes for the icon in stack 2x. The following special attributes are supported:
|
| return | string | The html formatted icon |
|---|---|---|
| throws | yii\base\InvalidConfigException | |