Skip to content

Commit 1861d67

Browse files
committed
Merge pull request #42 from grouse/html-icon-options
Reuse HtmlHelper::tag and allow for options to be passed to function,…
2 parents 44ec800 + 76d2ed6 commit 1861d67

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/View/Helper/BootstrapHtmlHelper.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,32 @@ public function __construct (\Cake\View\View $view, array $config = []) {
4949
* @param $icon Name of the icon.
5050
*
5151
**/
52-
public function icon ($icon) {
53-
return $this->_useFontAwesome ? $this->faIcon($icon) : $this->glIcon($icon);
52+
public function icon ($icon, $options = array()) {
53+
return $this->_useFontAwesome ? $this->faIcon($icon, $options) : $this->glIcon($icon, $options);
5454
}
5555

5656
/**
5757
* Create a font awesome icon.
5858
*
5959
* @param $icon Name of the icon.
6060
*/
61-
public function faIcon ($icon) {
62-
return '<i class="fa fa-'.$icon.'"></i>' ;
61+
public function faIcon ($icon, $options = array()) {
62+
$options = $this->addClass($options, 'fa');
63+
$options = $this->addClass($options, 'fa-'.$icon);
64+
65+
return $this->tag('i', '', $options);
6366
}
6467

6568
/**
6669
* Create a glyphicon icon.
6770
*
6871
* @param $icon Name of the icon.
6972
*/
70-
public function glIcon ($icon) {
71-
return '<i class="glyphicon glyphicon-'.$icon.'"></i>';
73+
public function glIcon ($icon, $options = array()) {
74+
$options = $this->addClass($options, 'glyphicon');
75+
$options = $this->addClass($options, 'glyphicon-'.$icon);
76+
77+
return $this->tag('i', '', $options);
7278
}
7379

7480
/**

0 commit comments

Comments
 (0)