From aeae59285e8a9c2ba6e5a9d9668c0c2c370ee60d Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 4 Oct 2021 13:06:41 +0200 Subject: [PATCH] chg: [helper:bootstrap] Support of picture in buttons --- src/View/Helper/BootstrapHelper.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/View/Helper/BootstrapHelper.php b/src/View/Helper/BootstrapHelper.php index cf82729..287696f 100644 --- a/src/View/Helper/BootstrapHelper.php +++ b/src/View/Helper/BootstrapHelper.php @@ -836,6 +836,7 @@ class BoostrapButton extends BootstrapGeneric { 'outline' => false, 'size' => '', 'icon' => null, + 'image' => null, 'class' => [], 'type' => 'button', 'nodeType' => 'button', @@ -894,6 +895,7 @@ class BoostrapButton extends BootstrapGeneric { ])); $html .= $this->genIcon(); + $html .= $this->genImage(); $html .= $this->genContent(); if (!empty($this->options['badge'])) { $bsBadge = new BoostrapBadge($this->options['badge']); @@ -905,10 +907,27 @@ class BoostrapButton extends BootstrapGeneric { private function genIcon() { - $bsIcon = new BoostrapIcon($this->options['icon'], [ - 'class' => [(!empty($this->options['title']) ? 'me-1' : '')] - ]); - return $bsIcon->icon(); + if (!empty($this->options['icon'])) { + $bsIcon = new BoostrapIcon($this->options['icon'], [ + 'class' => [(!empty($this->options['title']) ? 'me-1' : '')] + ]); + return $bsIcon->icon(); + } + return ''; + } + + private function genImage() + { + if (!empty($this->options['image'])) { + return $this->genNode('img', [ + 'src' => $this->options['image']['path'] ?? '', + 'class' => ['img-fluid', 'me-1'], + 'width' => '26', + 'height' => '26', + 'alt' => $this->options['image']['alt'] ?? '' + ]); + } + return ''; } private function genContent()