Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 15 |
| Banner | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 15 |
| init | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 15 |
|||
| <?php | |
| /** | |
| * @copyright Copyright (c) 2015 Maciej Klemarczyk | |
| * @license MIT License | |
| */ | |
| namespace common\widgets; | |
| /** | |
| * Banner widget renders an img tag with banner image for given key. | |
| * | |
| * @author Maciej Klemarczyk <m.klemarczyk@live.com> | |
| */ | |
| class Banner extends \yii\bootstrap\Widget | |
| { | |
| public $key; | |
| public $imageOptions = []; | |
| public function init() | |
| { | |
| parent::init(); | |
| $banner = \common\models\Banner::findOne($this->key); | |
| if (!empty($banner->imageUrl)) { | |
| $imageOptions = \yii\helpers\ArrayHelper::merge( | |
| [ | |
| 'style' => 'width: 100%; height: 140px;', | |
| 'width' => '140', | |
| 'height' => '140', | |
| ], | |
| $this->imageOptions | |
| ); | |
| echo \yii\helpers\Html::img($banner->imageUrl, $imageOptions); | |
| } | |
| } | |
| } |