File tree Expand file tree Collapse file tree 2 files changed +105
-0
lines changed Expand file tree Collapse file tree 2 files changed +105
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace hiqdev \yii2 \modules \pages \components ;
4
+
5
+ use hipanel \helpers \ArrayHelper ;
6
+ use hiqdev \yii2 \modules \pages \interfaces \PageInterface ;
7
+ use Yii ;
8
+ use yii \helpers \Inflector ;
9
+
10
+ /**
11
+ * Class AdditionalPage
12
+ * @package hiqdev\yii2\modules\pages\components
13
+ */
14
+ class AdditionalPage implements PageInterface
15
+ {
16
+ /**
17
+ * @var string
18
+ */
19
+ private $ label ;
20
+
21
+ /**
22
+ * @var string
23
+ */
24
+ private $ dictionary ;
25
+
26
+ /**
27
+ * @var string
28
+ */
29
+ private $ pathToPage ;
30
+
31
+ /**
32
+ * @var array
33
+ */
34
+ private $ params ;
35
+
36
+ /**
37
+ * AdditionalPage constructor.
38
+ * @param string $label
39
+ * @param array $label
40
+ * @param array $params
41
+ */
42
+ public function __construct (string $ label , array $ params = [])
43
+ {
44
+ $ this ->label = $ label ;
45
+ $ this ->dictionary = ArrayHelper::remove ($ params , 'dictionary ' );
46
+ $ this ->pathToPage = ArrayHelper::remove ($ params , 'path ' );
47
+ $ this ->params = $ params ;
48
+ }
49
+
50
+ /**
51
+ * @return string
52
+ */
53
+ public function getId (): string
54
+ {
55
+ return Inflector::slug ($ this ->label );
56
+ }
57
+
58
+ /**
59
+ * @return string
60
+ */
61
+ public function getLabel (): string
62
+ {
63
+ return Yii::t ($ this ->dictionary , $ this ->label );
64
+ }
65
+
66
+ /**
67
+ * @param array $params
68
+ * @return string
69
+ */
70
+ public function render (array $ params = []): string
71
+ {
72
+ return Yii::$ app ->view ->renderFile ($ this ->pathToPage , array_merge ($ this ->params , $ params ));
73
+ }
74
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace hiqdev \yii2 \modules \pages \components ;
4
+
5
+ use Yii ;
6
+ use yii \base \Component ;
7
+
8
+ class AdditionalPages extends Component
9
+ {
10
+ /**
11
+ * @return AdditionalPage[]
12
+ */
13
+ public static function getPages (): array
14
+ {
15
+ $ pages = Yii::$ app ->params ['module.pages.additional.rules ' ];
16
+
17
+ if (empty ($ pages )) {
18
+ return [];
19
+ }
20
+
21
+ $ list = [];
22
+ foreach ($ pages as $ label => $ params ) {
23
+ $ list [] = new AdditionalPage ($ label , array_merge ($ params , [
24
+ 'registrarName ' => Yii::$ app ->params ['organization.name ' ],
25
+ 'registrarUrl ' => Yii::$ app ->params ['organization.url ' ],
26
+ ]));
27
+ }
28
+
29
+ return $ list ;
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments