/
BreadcrumbsPanel.php
53 lines (42 loc) · 1.57 KB
/
BreadcrumbsPanel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace keygenqt\breadcrumbsPanel;
class BreadcrumbsPanel extends \yii\base\Widget
{
public static $links = [];
public static $icon = '';
public $breadcrumbsOptions = [];
public $backLink = 'Back to page';
public $homeLink = true;
public $content;
public static $_init = false;
public function run()
{
FontAwesomeAsset::register($this->getView());
ActiveAssets::register($this->getView());
if ($this->backLink) {
$exist = false;
$class = \Yii::$app->controller;
while (($class = get_parent_class($class)) !== false) {
if ('keygenqt\lastPage\LastPage' == $class) {
$exist = true;
break;
}
}
if (!$exist) {
$className = preg_replace('/.+\\\(.+)/ui', '$1', get_class(\Yii::$app->controller));
$classNamespase = preg_replace('/(.+)\\\.+/ui', '$1', get_class(\Yii::$app->controller));
throw new \yii\base\Exception("Сonnect LastPage (more: https://github.com/keygenqt/yii2-last-page)
namespace $classNamespase;
class $className extends \keygenqt\lastPage\LastPage {
...
");
}
}
return $this->getView()->render('@keygenqt/breadcrumbsPanel/views/view', ['widget' => $this]);
}
public static function setParams($links, $icon = '')
{
self::$links = $links;
self::$icon = $icon;
}
}