Completed
Push — master ( 77dac5...f300ba )
by Klochok
02:02
created

LogoLink::getAssetImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Theme Manager for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-thememanager
6
 * @package   yii2-thememanager
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\thememanager\widgets;
12
13
use Yii;
14
use yii\base\Widget;
15
16
/**
17
 * LogoLink widget.
18
 */
19
class LogoLink extends Widget
20
{
21
    /**
22
     * @var array html options
23
     */
24
    public $options = [];
25
26
    /**
27
     * @var string url to image
28
     */
29
    public $image;
30
31
    /**
32
     * @var string text to display
33
     */
34
    public $name;
35
36
    /**
37
     * @var array|string text to display
38
     */
39
    public $url;
40
41
    public function run()
42
    {
43
        return $this->render('LogoLink', $this->collectData());
44
    }
45
46
    protected function collectData()
47
    {
48
        $data = [
49
            'name'    => $this->name,
50
            'url'     => $this->url,
51
            'options' => $this->options,
52
        ];
53
        if ($this->image) {
54
            $data['image'] = $this->getAssetImage($this->image);
55
        }
56
57
        return $data;
58
    }
59
60
    protected function getAssetImage($image)
61
    {
62
        return Yii::$app->assetManager->publish($image)[1];
63
    }
64
}
65