|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the flysystem-bundle project. |
| 5 | + * |
| 6 | + * (c) Titouan Galopin <galopintitouan@gmail.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace League\FlysystemBundle\Adapter\Builder; |
| 13 | + |
| 14 | +use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter; |
| 15 | +use Symfony\Component\DependencyInjection\Definition; |
| 16 | +use Symfony\Component\DependencyInjection\Reference; |
| 17 | +use Symfony\Component\OptionsResolver\OptionsResolver; |
| 18 | + |
| 19 | +/** |
| 20 | + * @author Titouan Galopin <galopintitouan@gmail.com> |
| 21 | + */ |
| 22 | +class GcloudAdapterDefinitionBuilder extends AbstractAdapterDefinitionBuilder |
| 23 | +{ |
| 24 | + public function getName(): string |
| 25 | + { |
| 26 | + return 'gcloud'; |
| 27 | + } |
| 28 | + |
| 29 | + protected function configureOptions(OptionsResolver $resolver) |
| 30 | + { |
| 31 | + $resolver->setRequired('client'); |
| 32 | + $resolver->setAllowedTypes('client', 'string'); |
| 33 | + |
| 34 | + $resolver->setRequired('bucket'); |
| 35 | + $resolver->setAllowedTypes('bucket', 'string'); |
| 36 | + |
| 37 | + $resolver->setDefault('prefix', ''); |
| 38 | + $resolver->setAllowedTypes('prefix', 'string'); |
| 39 | + |
| 40 | + $resolver->setDefault('api_url', null); |
| 41 | + $resolver->setAllowedTypes('api_url', ['string', 'null']); |
| 42 | + } |
| 43 | + |
| 44 | + protected function configureDefinition(Definition $definition, array $options) |
| 45 | + { |
| 46 | + $bucketDefinition = new Definition(); |
| 47 | + $bucketDefinition->setFactory([new Reference($options['client']), 'bucket']); |
| 48 | + $bucketDefinition->setArgument(0, $options['bucket']); |
| 49 | + |
| 50 | + $definition->setClass(GoogleStorageAdapter::class); |
| 51 | + $definition->setArgument(0, new Reference($options['client'])); |
| 52 | + $definition->setArgument(1, $bucketDefinition); |
| 53 | + $definition->setArgument(2, $options['prefix']); |
| 54 | + $definition->setArgument(3, $options['api_url']); |
| 55 | + } |
| 56 | +} |
0 commit comments