From 76d2ed670c047b24b7c7057c6ceb3086da385ab5 Mon Sep 17 00:00:00 2001 From: Jesper Stefansson Date: Sat, 8 Aug 2015 15:58:05 +0200 Subject: [PATCH] Reuse HtmlHelper::tag and allow for options to be passed to function, in order to e.g. set mouse over title of icon --- src/View/Helper/BootstrapHtmlHelper.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/View/Helper/BootstrapHtmlHelper.php b/src/View/Helper/BootstrapHtmlHelper.php index cb42e8e..1f02419 100644 --- a/src/View/Helper/BootstrapHtmlHelper.php +++ b/src/View/Helper/BootstrapHtmlHelper.php @@ -49,8 +49,8 @@ public function __construct (\Cake\View\View $view, array $config = []) { * @param $icon Name of the icon. * **/ - public function icon ($icon) { - return $this->_useFontAwesome ? $this->faIcon($icon) : $this->glIcon($icon); + public function icon ($icon, $options = array()) { + return $this->_useFontAwesome ? $this->faIcon($icon, $options) : $this->glIcon($icon, $options); } /** @@ -58,8 +58,11 @@ public function icon ($icon) { * * @param $icon Name of the icon. */ - public function faIcon ($icon) { - return '' ; + public function faIcon ($icon, $options = array()) { + $options = $this->addClass($options, 'fa'); + $options = $this->addClass($options, 'fa-'.$icon); + + return $this->tag('i', '', $options); } /** @@ -67,8 +70,11 @@ public function faIcon ($icon) { * * @param $icon Name of the icon. */ - public function glIcon ($icon) { - return ''; + public function glIcon ($icon, $options = array()) { + $options = $this->addClass($options, 'glyphicon'); + $options = $this->addClass($options, 'glyphicon-'.$icon); + + return $this->tag('i', '', $options); } /**