-
Notifications
You must be signed in to change notification settings - Fork 11
/
AwsSdk.php
65 lines (59 loc) · 1.56 KB
/
AwsSdk.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
<?php
/**
* @copyright Federico Nicolás Motta
* @author Federico Nicolás Motta <[email protected]>
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
* @package yii2-aws-sdk
*/
namespace fedemotta\awssdk;
use yii\base\Component;
use Aws;
/**
* Yii2 component wrapping of the AWS SDK for easy configuration
* @author Federico Nicolás Motta <[email protected]>
*/
class AwsSdk extends Component
{
/*
* @var array specifies the AWS credentials
*/
public $credentials = [];
/*
* @var string specifies the AWS region
*/
public $region = null;
/*
* @var string specifies the AWS version
*/
public $version = null;
/*
* @var array specifies extra params
*/
public $extra = [];
/**
* @var Aws\Sdk instance
*/
protected $_awssdk;
/**
* Initializes (if needed) and fetches the AWS SDK instance
* @return Aws\Sdk instance
*/
public function getAwsSdk()
{
if (empty($this->_awssdk) || !$this->_awssdk instanceof Aws\Sdk) {
$this->setAwsSdk();
}
return $this->_awssdk;
}
/**
* Sets the AWS SDK instance
*/
public function setAwsSdk()
{
$this->_awssdk = new Aws\Sdk(array_merge([
'credentials' => $this->credentials,
'region'=>$this->region,
'version'=>$this->version
],$this->extra));
}
}