1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: dsmrt |
5
|
|
|
* Date: 3/9/18 |
6
|
|
|
* Time: 2:48 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace flipbox\saml\core\controllers\cp\view; |
10
|
|
|
|
11
|
|
|
use craft\helpers\UrlHelper; |
12
|
|
|
use flipbox\saml\core\EnsureSAMLPlugin; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class AbstractGeneralController |
16
|
|
|
* @package flipbox\saml\core\controllers\cp\view |
17
|
|
|
*/ |
18
|
|
|
abstract class AbstractGeneralController extends AbstractController implements EnsureSAMLPlugin |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
const TEMPLATE_INDEX = DIRECTORY_SEPARATOR . '_cp'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return \yii\web\Response |
25
|
|
|
*/ |
26
|
|
|
public function actionIndex() |
27
|
|
|
{ |
28
|
|
|
return $this->actionSetup(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return \yii\web\Response |
33
|
|
|
*/ |
34
|
|
|
public function actionSetup() |
35
|
|
|
{ |
36
|
|
|
$variables = $this->getBaseVariables(); |
37
|
|
|
$variables['crumbs'][] = [ |
38
|
|
|
'url' => UrlHelper::cpUrl($this->getPlugin()->getHandle()), |
39
|
|
|
'label' => 'SSO Provider' |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
return $this->renderTemplate( |
43
|
|
|
$this->getTemplateIndex() . static::TEMPLATE_INDEX . DIRECTORY_SEPARATOR . 'setup', |
44
|
|
|
$variables |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return \yii\web\Response |
51
|
|
|
*/ |
52
|
|
|
public function actionSettings() |
53
|
|
|
{ |
54
|
|
|
$variables = $this->getBaseVariables(); |
55
|
|
|
|
56
|
|
|
// Breadcrumbs |
57
|
|
|
$variables['crumbs'][] = [ |
58
|
|
|
'url' => UrlHelper::cpUrl($this->getPlugin()->getHandle()), |
59
|
|
|
'label' => 'SSO Provider' |
60
|
|
|
]; |
61
|
|
|
$variables['crumbs'][] = [ |
62
|
|
|
'url' => UrlHelper::cpUrl($this->getPlugin()->getHandle() . '/settings'), |
63
|
|
|
'label' => 'Settings' |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* base action path |
68
|
|
|
* @see AbstractUpdate |
69
|
|
|
*/ |
70
|
|
|
$variables['baseActionPath'] = $this->getBaseActionPath(); |
71
|
|
|
|
72
|
|
|
// tell craft to make it a form |
73
|
|
|
$variables['fullPageForm'] = true; |
74
|
|
|
|
75
|
|
|
return $this->renderTemplate( |
76
|
|
|
$this->getTemplateIndex() . static::TEMPLATE_INDEX . DIRECTORY_SEPARATOR . 'settings', |
77
|
|
|
$variables |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Piece together the action url |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
private function getBaseActionPath() |
86
|
|
|
{ |
87
|
|
|
return implode( |
88
|
|
|
'/', |
89
|
|
|
[ |
90
|
|
|
$this->getPlugin()->getHandle(), |
91
|
|
|
'settings', |
92
|
|
|
] |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|