Completed
Push — develop ( 6a2a65...4fcbf9 )
by Nate
07:38
created

AbstractController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 72
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseActionPath() 0 4 1
A getBaseCpPath() 0 4 1
A getBaseContinueEditingUrl() 0 4 1
A baseVariables() 0 28 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/flux/license
6
 * @link       https://www.flipboxfactory.com/software/flux/
7
 */
8
9
namespace flipbox\flux\cp\controllers\view;
10
11
use Craft;
12
use craft\web\Controller;
13
use flipbox\ember\helpers\UrlHelper;
14
use flipbox\organizations\cp\Cp as CpModule;
15
use flipbox\organizations\Organizations as OrganizationPlugin;
16
17
/**
18
 * @author Flipbox Factory <[email protected]>
19
 * @since 1.0.0
20
 *
21
 * @property CpModule $module
22
 */
23
abstract class AbstractController extends Controller
24
{
25
    /**
26
     * The index view template path
27
     */
28
    const TEMPLATE_BASE = 'flux/_cp';
29
30
    /*******************************************
31
     * BASE PATHS
32
     *******************************************/
33
34
    /**
35
     * @return string
36
     */
37
    protected function getBaseActionPath(): string
38
    {
39
        return OrganizationPlugin::getInstance()->getUniqueId() . '/cp';
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    protected function getBaseCpPath(): string
46
    {
47
        return OrganizationPlugin::getInstance()->getUniqueId();
48
    }
49
50
    /**
51
     * @param string $endpoint
52
     * @return string
53
     */
54
    protected function getBaseContinueEditingUrl(string $endpoint = ''): string
55
    {
56
        return $this->getBaseCpPath() . $endpoint;
57
    }
58
59
    /*******************************************
60
     * VARIABLES
61
     *******************************************/
62
63
    /**
64
     * @inheritdoc
65
     */
66
    protected function baseVariables(array &$variables = [])
67
    {
68
        $module = OrganizationPlugin::getInstance();
69
70
        $title = Craft::t('flux', "Flux");
71
72
        // Settings
73
        $variables['settings'] = $module->getSettings();
74
        $variables['title'] = $title;
75
76
        // Path to controller actions
77
        $variables['baseActionPath'] = $this->getBaseActionPath();
78
79
        // Path to CP
80
        $variables['baseCpPath'] = $this->getBaseCpPath();
81
82
        // Set the "Continue Editing" URL
83
        $variables['continueEditingUrl'] = $this->getBaseCpPath();
84
85
        // Select our sub-nav
86
        $variables['selectedSubnavItem'] = 'flux.flux';
87
88
        // Breadcrumbs
89
        $variables['crumbs'][] = [
90
            'label' => $title,
91
            'url' => UrlHelper::url(OrganizationPlugin::getInstance()->getUniqueId())
92
        ];
93
    }
94
}
95