1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SaaS Link plugin for Craft CMS 3.x |
4
|
|
|
* |
5
|
|
|
* @link https://workingconcept.com |
6
|
|
|
* @copyright Copyright (c) 2018 Working Concept Inc. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace workingconcept\saaslink\services; |
10
|
|
|
|
11
|
|
|
class SaasLinkService extends \craft\base\Component |
12
|
|
|
{ |
13
|
|
|
// Properties |
14
|
|
|
// ========================================================================= |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var \workingconcept\saaslink\models\Settings |
18
|
|
|
*/ |
19
|
|
|
public $settings; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The base URL used to interact with the SaaS API. |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $apiBaseUrl; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The human-friendly name of the service. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public $serviceName; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* A slugified name of the service. |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $serviceSlug; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Guzzle client to be configured and used for API interaction. |
44
|
|
|
* |
45
|
|
|
* @var \GuzzleHttp\Client |
46
|
|
|
*/ |
47
|
|
|
protected $client; |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
// Public Methods |
51
|
|
|
// ========================================================================= |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritdoc |
55
|
|
|
*/ |
56
|
|
|
public function init() |
57
|
|
|
{ |
58
|
|
|
parent::init(); |
59
|
|
|
|
60
|
|
|
// populate the settings |
61
|
|
|
$this->settings = \workingconcept\saaslink\SaasLink::$plugin->getSettings(); |
62
|
|
|
|
63
|
|
|
if ($this->isConfigured()) |
64
|
|
|
{ |
65
|
|
|
$this->configureClient(); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Determine whether we're ready to interact with the service. |
72
|
|
|
* |
73
|
|
|
* @return boolean |
74
|
|
|
*/ |
75
|
|
|
public function isConfigured(): bool |
76
|
|
|
{ |
77
|
|
|
return false; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Configure Guzzle ->client to interact with the API. |
83
|
|
|
* |
84
|
|
|
* @return void |
85
|
|
|
*/ |
86
|
|
|
public function configureClient() |
87
|
|
|
{ |
88
|
|
|
// ready $this->client ! |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get an array of label+value options that represent service Objeccts |
94
|
|
|
* that may act as link targets. |
95
|
|
|
* |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
|
|
public function getAvailableRelationshipTypes(): array |
99
|
|
|
{ |
100
|
|
|
return []; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get an array of label+value options that represent instances of whatever |
106
|
|
|
* relationshipType object was chosen. (Things to link to.) |
107
|
|
|
* |
108
|
|
|
* @param string $relationshipType |
109
|
|
|
* |
110
|
|
|
* @return array |
111
|
|
|
*/ |
112
|
|
|
public function getOptions($relationshipType): array |
|
|
|
|
113
|
|
|
{ |
114
|
|
|
return []; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.