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