Skip to content

Commit

Permalink
Update Icon.php
Browse files Browse the repository at this point in the history
  • Loading branch information
cuileon authored Apr 22, 2018
1 parent d464fcb commit 211a1c8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
namespace yiichina\icons;

use yii\helpers\Html;
use yii\helpers\ArrayHelper;

/**
* This is just an example.
*/
class Icon extends \yii\base\Widget
{
/**
* @param $name 图标名称
* @param $options 选项参数
* @param $name string 图标名称
* @param $options array 图标参数
* @param $htmlOptions array HTML 参数
* @return string
*/
public static function show($name, $options = [])
public static function show($name, $options = [], $htmlOptions = [])
{
IconAsset::register(\Yii::$app->getView());
$type = ArrayHelper::remove($options, 'type', 'fas');
$tagName = ArrayHelper::remove($options, 'tagName', 'i');
$type = ArrayHelper::remove($options, 'type', 'fas');
$start = ArrayHelper::remove($options, 'start', null);
$end = ArrayHelper::remove($options, 'start', ' ');
ArrayHelper::setValue($options, 'class', "$type fa-$name");
return $start . Html::tag($tagName, null, $options) . $end;
$end = ArrayHelper::remove($options, 'end', ' ');
Html::addCssClass($htmlOptions, ['type' => $type, 'name' => 'fa-' . $name]);
return $start . Html::tag($tagName, null, $htmlOptions) . $end;
}
}

0 comments on commit 211a1c8

Please sign in to comment.