Completed
Push — develop ( 2d4f17...d5975b )
by Nate
05:25
created

AbstractController::getBaseCpPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\craft\hubspot\cp\controllers\settings\view;
10
11
use Craft;
12
use flipbox\craft\ember\helpers\UrlHelper;
13
use flipbox\craft\hubspot\cp\Cp as CpModule;
14
use flipbox\craft\hubspot\HubSpot;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 *
20
 * @property CpModule $module
21
 */
22
abstract class AbstractController extends \flipbox\craft\hubspot\cp\controllers\view\AbstractController
23
{
24
    /**
25
     * The index view template path
26
     */
27
    const TEMPLATE_BASE = parent::TEMPLATE_BASE . '/settings';
28
29
    /*******************************************
30
     * BASE PATHS
31
     *******************************************/
32
33
    /**
34
     * @return string
35
     */
36
    protected function getBaseActionPath(): string
37
    {
38
        return parent::getBaseActionPath() . '/settings';
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    protected function getBaseCpPath(): string
45
    {
46
        return parent::getBaseCpPath() . '/settings';
47
    }
48
49
    /**
50
     * @param string $endpoint
51
     * @return string
52
     */
53
    protected function getBaseContinueEditingUrl(string $endpoint = ''): string
54
    {
55
        return $this->getBaseCpPath() . $endpoint;
56
    }
57
58
    /*******************************************
59
     * VARIABLES
60
     *******************************************/
61
62
    /**
63
     * @inheritdoc
64
     */
65
    protected function baseVariables(array &$variables = [])
66
    {
67
        parent::baseVariables($variables);
68
69
        $title = Craft::t('hubspot', "Settings");
70
        $variables['title'] .= ': ' . $title;
71
72
        // Breadcrumbs
73
        $variables['crumbs'][] = [
74
            'label' => $title,
75
            'url' => UrlHelper::url(HubSpot::getInstance()->getUniqueId())
76
        ];
77
    }
78
79
    /*******************************************
80
     * UPSERT VARIABLES
81
     *******************************************/
82
83
    /**
84
     * @param array $variables
85
     */
86
    protected function insertVariables(array &$variables)
87
    {
88
        $this->baseVariables($variables);
89
        $variables['continueEditingUrl'] = $this->getBaseContinueEditingUrl('/{id}');
90
        $variables['title'] .= ' - ' . Craft::t('hubspot', 'New');
91
    }
92
}
93