Completed
Push — master ( 72ecff...582962 )
by Damien
11:32
created

AbstractGeneralController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 78
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A actionSettings() 0 28 1
A getBaseActionPath() 0 10 1
A actionIndex() 0 4 1
A actionSetup() 0 13 1
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