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\web\twig\variables; |
10
|
|
|
|
11
|
|
|
use Craft; |
12
|
|
|
use flipbox\craft\hubspot\HubSpot as HubSpotPlugin; |
13
|
|
|
use flipbox\craft\hubspot\models\Settings; |
14
|
|
|
use flipbox\craft\hubspot\services\Cache; |
15
|
|
|
use flipbox\craft\hubspot\services\Connections; |
16
|
|
|
use yii\di\ServiceLocator; |
17
|
|
|
use yii\helpers\Json; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Flipbox Factory <[email protected]> |
21
|
|
|
* @since 1.0.0 |
22
|
|
|
*/ |
23
|
|
|
class HubSpot extends ServiceLocator |
24
|
|
|
{ |
25
|
|
|
use VisitorTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @inheritdoc |
29
|
|
|
*/ |
30
|
|
|
public function init() |
31
|
|
|
{ |
32
|
|
|
parent::init(); |
33
|
|
|
|
34
|
|
|
$this->setComponents([ |
35
|
|
|
'cache' => HubSpotPlugin::getInstance()->getCache(), |
36
|
|
|
'connections' => HubSpotPlugin::getInstance()->getConnections(), |
37
|
|
|
'criteria' => Criteria::class |
38
|
|
|
]); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Sub-Variables that are accessed 'craft.hubspot.settings' |
43
|
|
|
* |
44
|
|
|
* @return Settings |
45
|
|
|
*/ |
46
|
|
|
public function getSettings() |
47
|
|
|
{ |
48
|
|
|
return HubSpotPlugin::getInstance()->getSettings(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @noinspection PhpDocMissingThrowsInspection |
53
|
|
|
* @return Cache |
54
|
|
|
*/ |
55
|
|
|
public function getCache(): Cache |
56
|
|
|
{ |
57
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
58
|
|
|
/** @noinspection PhpIncompatibleReturnTypeInspection */ |
59
|
|
|
return $this->get('cache'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @noinspection PhpDocMissingThrowsInspection |
64
|
|
|
* @return Connections |
65
|
|
|
*/ |
66
|
|
|
public function getConnections(): Connections |
67
|
|
|
{ |
68
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
69
|
|
|
/** @noinspection PhpIncompatibleReturnTypeInspection */ |
70
|
|
|
return $this->get('connections'); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|