Added icon wrapper class

This commit is contained in:
Lucas Bartholemy 2018-12-06 17:40:37 +01:00
parent 9fb44d0789
commit fda7c99c73
2 changed files with 57 additions and 0 deletions

View File

@ -7,5 +7,7 @@ HumHub Change Log (DEVELOP)
- Enh: GroupPermissionManager - allow to query users by given permission
- Enh: Automatic migrate DB collations from utf8 to utf8mb4
- Enh: Added Icon widget as wrapper class

View File

@ -0,0 +1,55 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\ui\widgets;
use humhub\components\Widget;
/**
* Class Icon
*
* Wrapper class for icon handling.
* Currently this class only supports FontAwesome 4.7 icons
*
* @since 1.4
* @package humhub\modules\ui\widgets
*/
class Icon extends Widget
{
/**
* @var string the name/id of the icon
*/
public $name;
/**
* @return string returns the Html tag for the current icon
*/
public function renderHtml()
{
return '<i class="fa fa-' . $this->name . '"></i>';
}
/**
* @inheritdoc
*/
public function run()
{
return $this->renderHtml();
}
/**
* @return string returns the Html tag for this icon
*/
public function __toString()
{
return $this->renderHtml();
}
}