-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathAwsFactory.php
46 lines (40 loc) · 1.12 KB
/
AwsFactory.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
<?php
namespace AwsModule\Factory;
use Aws\Sdk as AwsSdk;
use AwsModule\Module;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
/**
* Factory used to instantiate an AWS client
*/
class AwsFactory implements FactoryInterface
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return AwsSdk
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
// Instantiate the AWS SDK for PHP
$config = $container->get('Config');
$config = isset($config['aws']) ? $config['aws'] : [];
$config += [
'ua_append' => [
'ZF2/' . Module::VERSION,
'ZFMOD/' . Module::VERSION,
]
];
return new AwsSdk($config);
}
/**
* {@inheritDoc}
* @return AwsSdk
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return $this($serviceLocator, AwsSdk::class);
}
}