-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Soundcloud.php
99 lines (91 loc) · 2.19 KB
/
Soundcloud.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
* @deprecated since 1.0.4
*/
namespace humhub\modules\user\authclient;
use yii\authclient\OAuth2;
use yii\base\InvalidConfigException;
class Soundcloud extends OAuth2
{
/**
* @inheritdoc
*/
protected function defaultViewOptions()
{
return [
'popupWidth' => 860,
'popupHeight' => 480,
'cssIcon' => 'fa fa-soundcloud',
'buttonBackgroundColor' => '#395697',
];
}
/**
* @var string Soundcloud Client ID
*/
protected $clientId;
/**
* @var string Soundcloud Client Secret
*/
protected $clientSecret;
/**
* @var string Soundcloud Auth Callback Url
*/
protected $callbackUrl;
/**
* @inheritdoc
*/
protected $soundcloud;
public function __construct($config = [])
{
foreach ($config as $param => $value) {
$this->$param = $value;
}
$this->validateParameters();
$this->init();
}
/**
* Validates supplied Params.
*
* @return void
* @throws InvalidConfigException
*/
protected function validateParameters()
{
if (empty($this->clientId) || !is_string($this->clientId)) {
throw new InvalidConfigException("clientId cannot be empty and it must be a string");
}
if (empty($this->clientSecret) || !is_string($this->clientSecret)) {
throw new InvalidConfigException("clientSecret cannot be empty and it must be a string");
}
}
/**
* {@inheritdoc}
*
* @return void
*/
public function init()
{
$this->soundcloud = new Sc($this->clientId, $this->clientSecret, $this->callbackUrl);
}
public function __call($method, $args = [])
{
return call_user_func_array(array($this->soundcloud, $method), $args);
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'soundcloud';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Soundcloud';
}
}