From fb171e06557a8bc445e8b30063992e68d75ff870 Mon Sep 17 00:00:00 2001 From: cbeauvoi Date: Wed, 20 Feb 2019 12:36:07 +0100 Subject: [PATCH] debug --- StorageBundle/Adaptors/S3Storage.php | 2 ++ StorageBundle/Storage.php | 42 +++++++++--------------------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/StorageBundle/Adaptors/S3Storage.php b/StorageBundle/Adaptors/S3Storage.php index 9f48b61..b369a55 100644 --- a/StorageBundle/Adaptors/S3Storage.php +++ b/StorageBundle/Adaptors/S3Storage.php @@ -25,6 +25,8 @@ class S3Storage $this->config = $config; $this->bucket = $config['bucket']; + dump($this); die; + $this->client = new S3Client([ 'version' => isset($config['version']) ? $config['version'] : 'latest', 'region' => $config['region'], diff --git a/StorageBundle/Storage.php b/StorageBundle/Storage.php index 3da7140..d857cec 100644 --- a/StorageBundle/Storage.php +++ b/StorageBundle/Storage.php @@ -3,6 +3,7 @@ namespace Bluesquare\StorageBundle; use Aws\S3\S3Client; +use Bluesquare\StorageBundle\Adaptors\S3Storage; /** * Interface de manipulation des stockages préconfigurés @@ -10,46 +11,23 @@ use Aws\S3\S3Client; */ class Storage { - private $user_config = []; + private $config_storage = []; public function __construct(array $user_config = []) { - $this->user_config = $user_config; + $this->config_storage = $user_config; } public function get($storage_name) { - // TODO: on récupère les infos sur ce storage dans la config utilisateur (config/bluesquare/storage.yaml) - // La clef pour la configuration d'un storage devrait être : "storage.{storage_name}" + if (array_key_exists($storage_name, $this->config_storage)) + { + $config = $this->config_storage[$storage_name]; -// dump($this); die; - // Si storage.{storage_name}.type == 's3' alors : -// return new S3Storage($storage_name, $config); // $config c'est le contenu de storage.{storage_name} sous forme de tableau + if ($config['type'] == 's3') + return new S3Storage($storage_name, $config); + } - // Sinon : - return null; // (on ajoutera d'autres types de stockage plus tard, dont le stockage de fichier sur le serveur actuel) + return null; } } - -//storage: -//photos: -// type: s3 -// bucket: bluesquare.public -// region: nl-ams -// endpoint: 'https://s3.nl-ams.scw.cloud' -// credentials: -// key: '%env(MYSUPERSECRETAWSKEY)%' -// secret: '%env(MYSUPERSECRETAWSSECRET)%' -// version: lastest # optionnel -// path: '/photos' # optionnel -// -// files: -// type: s3 -// bucket: bluesquare.private -// region: nl-ams -// endpoint: 'https://s3.nl-ams.scw.cloud' -// credentials: -// key: '%env(MYSUPERSECRETAWSKEY)%' -// secret: '%env(MYSUPERSECRETAWSSECRET)%' -// -// ...