@@ -136,24 +136,45 @@ private function createAwsClient($config, ContainerBuilder $container, $name)
136136
137137 if (!$ container ->hasDefinition ($ service )) {
138138
139- if (!class_exists ('Aws\Common\Aws ' )) {
139+ $ aws2 = class_exists ('Aws\Common\Aws ' );
140+ $ aws3 = class_exists ('Aws\Sdk ' );
141+ if (!$ aws2 && !$ aws3 ) {
140142 throw new \RuntimeException (
141143 'You must require "aws/aws-sdk-php" to use the AWS provider. '
142144 );
143145 }
144146
145- $ awsConfig = [];
146- if (!empty ($ config ['key ' ]) && !empty ($ config ['secret ' ])) {
147- $ awsConfig ['key ' ] = $ config ['key ' ];
148- $ awsConfig ['secret ' ] = $ config ['secret ' ];
149- }
150-
151- $ awsConfig ['region ' ] = $ config ['region ' ];
147+ $ awsConfig = [
148+ 'region ' => $ config ['region ' ]
149+ ];
152150
153151 $ aws = new Definition ('Aws\Common\Aws ' );
154152 $ aws ->setFactory (['Aws\Common\Aws ' , 'factory ' ]);
155153 $ aws ->setArguments ([$ awsConfig ]);
156154
155+ if ($ aws2 ) {
156+ $ aws = new Definition ('Aws\Common\Aws ' );
157+ $ aws ->setFactory (['Aws\Common\Aws ' , 'factory ' ]);
158+
159+ if (!empty ($ config ['key ' ]) && !empty ($ config ['secret ' ])) {
160+ $ awsConfig ['key ' ] = $ config ['key ' ];
161+ $ awsConfig ['secret ' ] = $ config ['secret ' ];
162+ }
163+
164+ } else {
165+ $ aws = new Definition ('Aws\Sdk ' );
166+
167+ if (!empty ($ config ['key ' ]) && !empty ($ config ['secret ' ])) {
168+ $ awsConfig ['credentials ' ] = [
169+ 'key ' => $ config ['key ' ],
170+ 'secret ' => $ config ['secret ' ]
171+ ];
172+ }
173+ $ awsConfig ['version ' ] = 'latest ' ;
174+ }
175+
176+ $ aws ->setArguments ([$ awsConfig ]);
177+
157178 $ container ->setDefinition ($ service , $ aws )
158179 ->setPublic (false );
159180 }
0 commit comments