|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace flipbox\patron\cp\controllers\view\providers; |
|
4
|
|
|
|
|
5
|
|
|
use Craft; |
|
6
|
|
|
use craft\helpers\UrlHelper; |
|
7
|
|
|
use flipbox\craft\assets\card\Card; |
|
8
|
|
|
use flipbox\craft\assets\circleicon\CircleIcon; |
|
9
|
|
|
use flipbox\ember\web\assets\rowinfomodal\RowInfoModal; |
|
10
|
|
|
use flipbox\patron\helpers\ProviderHelper as ProviderHelper; |
|
11
|
|
|
use flipbox\patron\Patron; |
|
12
|
|
|
use flipbox\patron\records\Provider; |
|
13
|
|
|
use flipbox\patron\records\ProviderInstance; |
|
14
|
|
|
use flipbox\patron\services\ManageProviders as ProviderService; |
|
15
|
|
|
use flipbox\patron\web\assets\providerswitcher\ProvidersAsset; |
|
16
|
|
|
|
|
17
|
|
|
class TokensController extends AbstractViewController |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* The index view template path |
|
21
|
|
|
*/ |
|
22
|
|
|
const TEMPLATE_INDEX = AbstractViewController::TEMPLATE_BASE . '/tokens'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* The upsert view template path |
|
26
|
|
|
*/ |
|
27
|
|
|
const TEMPLATE_INSERT = self::TEMPLATE_INDEX . '/index'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param null $identifier |
|
31
|
|
|
* @return \yii\web\Response |
|
32
|
|
|
* @throws \flipbox\ember\exceptions\NotFoundException |
|
33
|
|
|
* @throws \yii\base\InvalidConfigException |
|
34
|
|
|
*/ |
|
35
|
|
|
public function actionIndex($identifier = null) |
|
36
|
|
|
{ |
|
37
|
|
|
Craft::$app->getView()->registerAssetBundle(CircleIcon::class); |
|
38
|
|
|
Craft::$app->getView()->registerAssetBundle(RowInfoModal::class); |
|
39
|
|
|
|
|
40
|
|
|
// Empty variables for template |
|
41
|
|
|
$variables = []; |
|
42
|
|
|
|
|
43
|
|
|
$provider = Patron::getInstance()->manageProviders()->getByCondition([ |
|
44
|
|
|
'id' => $identifier, |
|
45
|
|
|
'environment' => null, |
|
46
|
|
|
'enabled' => null |
|
47
|
|
|
]); |
|
48
|
|
|
|
|
49
|
|
|
// Template variables |
|
50
|
|
|
$this->tokenVariables($variables, $provider); |
|
51
|
|
|
|
|
52
|
|
|
$variables['provider'] = $provider; |
|
53
|
|
|
|
|
54
|
|
|
// Tabs |
|
55
|
|
|
$variables['tabs'] = $this->getTabs($provider); |
|
56
|
|
|
$variables['selectedTab'] = 'tokens'; |
|
57
|
|
|
|
|
58
|
|
|
return $this->renderTemplate(static::TEMPLATE_INDEX, $variables); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/******************************************* |
|
62
|
|
|
* PATHS |
|
63
|
|
|
*******************************************/ |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @inheritdoc |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function getBaseCpPath(): string |
|
69
|
|
|
{ |
|
70
|
|
|
return parent::getBaseCpPath() . '/' . Craft::$app->getRequest()->getSegment(3); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @inheritdoc |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function getBaseActionPath(): string |
|
77
|
|
|
{ |
|
78
|
|
|
return parent::getBaseActionPath() . '/tokens'; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
/******************************************* |
|
83
|
|
|
* VARIABLES |
|
84
|
|
|
*******************************************/ |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param array $variables |
|
88
|
|
|
* @param Provider $provider |
|
89
|
|
|
*/ |
|
90
|
|
|
protected function tokenVariables(array &$variables, Provider $provider) |
|
91
|
|
|
{ |
|
92
|
|
|
$this->updateVariables($variables, $provider); |
|
93
|
|
|
|
|
94
|
|
|
$variables['title'] .= ' ' . Craft::t('patron', "Tokens"); |
|
95
|
|
|
|
|
96
|
|
|
// Breadcrumbs |
|
97
|
|
|
$variables['crumbs'][] = [ |
|
98
|
|
|
'label' => Craft::t('patron', "Tokens"), |
|
99
|
|
|
'url' => UrlHelper::url( |
|
100
|
|
|
$variables['baseCpPath'] . '/tokens' |
|
101
|
|
|
) |
|
102
|
|
|
]; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|