rmrevin\yii\fontawesome\component\Icon::addCssClass PHP Method

addCssClass() public method

public addCssClass ( string $class, boolean $condition = true, string | boolean $throw = false ) : Icon
$class string
$condition boolean
$throw string | boolean
return Icon
    public function addCssClass($class, $condition = true, $throw = false)
    {
        if ($condition === false) {
            if (!empty($throw)) {
                $message = !is_string($throw) ? 'Condition is false' : $throw;
                throw new \yii\base\InvalidConfigException($message);
            }
        } else {
            Html::addCssClass($this->options, $class);
        }
        return $this;
    }

Usage Example

Example #1
0
 /**
  * @param string|null $tag
  * @param array $options
  * @return string
  * @throws \yii\base\InvalidConfigException
  */
 public function render($tag = null, $options = [])
 {
     $tag = empty($tag) ? empty($this->tag) ? static::$defaultTag : $this->tag : $tag;
     $options = array_merge($this->options, $options);
     $icon_back = $this->icon_back instanceof Icon ? $this->icon_back->addCssClass('fa-stack-2x') : null;
     $icon_front = $this->icon_front instanceof Icon ? $this->icon_front->addCssClass('fa-stack-1x') : null;
     return Html::tag($tag, $icon_back . $icon_front, $options);
 }
All Usage Examples Of rmrevin\yii\fontawesome\component\Icon::addCssClass