-
Notifications
You must be signed in to change notification settings - Fork 0
/
Icon.php
executable file
·51 lines (43 loc) · 1.11 KB
/
Icon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace makroxyz\materializecss;
use yii\base\InvalidConfigException;
/**
* Class Icon
* @package makroxyz\materializecss
*/
class Icon extends Widget
{
/**
* @var string the name of the icon
*
* @see http://materializecss.com/icons.html
*/
public $name;
/**
* @var array the HTML options for the "img" tag
*
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = [];
/**
* Initialize the widget.
*
* @throws InvalidConfigException if icon name is not specified
*/
public function init()
{
parent::init();
if (!$this->name) {
throw new InvalidConfigException('The icon name must be specified.');
}
Html::addCssClass($this->options, ['material-icons']);
}
/**
* Executes the widget.
* @return string the result of widget execution to be outputted.
*/
public function run()
{
return Html::tag('i', $this->name, $this->options);
}
}