2019-02-20 11:11:38 +01:00
|
|
|
<?php
|
|
|
|
|
2019-02-20 12:12:35 +01:00
|
|
|
namespace Bluesquare\StorageBundle;
|
2019-02-20 11:11:38 +01:00
|
|
|
|
|
|
|
use Aws\S3\S3Client;
|
2019-02-20 12:36:07 +01:00
|
|
|
use Bluesquare\StorageBundle\Adaptors\S3Storage;
|
2019-02-20 11:11:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface de manipulation des stockages préconfigurés
|
|
|
|
* Usage par injection
|
|
|
|
*/
|
|
|
|
class Storage
|
|
|
|
{
|
2019-02-20 12:36:07 +01:00
|
|
|
private $config_storage = [];
|
2019-02-20 12:19:03 +01:00
|
|
|
|
2019-02-20 12:30:09 +01:00
|
|
|
public function __construct(array $user_config = [])
|
2019-02-20 12:19:03 +01:00
|
|
|
{
|
2019-02-20 12:36:07 +01:00
|
|
|
$this->config_storage = $user_config;
|
2019-02-20 12:19:03 +01:00
|
|
|
}
|
|
|
|
|
2019-02-20 11:11:38 +01:00
|
|
|
public function get($storage_name)
|
|
|
|
{
|
2019-02-20 12:36:07 +01:00
|
|
|
if (array_key_exists($storage_name, $this->config_storage))
|
|
|
|
{
|
|
|
|
$config = $this->config_storage[$storage_name];
|
2019-02-20 11:11:38 +01:00
|
|
|
|
2019-02-20 12:36:07 +01:00
|
|
|
if ($config['type'] == 's3')
|
|
|
|
return new S3Storage($storage_name, $config);
|
|
|
|
}
|
2019-02-20 11:11:38 +01:00
|
|
|
|
2019-02-20 12:36:07 +01:00
|
|
|
return null;
|
2019-02-20 11:11:38 +01:00
|
|
|
}
|
|
|
|
}
|