mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-25 00:53:48 +00:00
Refactor TempUrlOpenstackGenerator to use parameter bag and Bundle configuration
The TempUrlOpenstackGenerator now uses a ParameterBag for configuration instead of individual parameters. This simplifies the handling of configuration values and makes the code more maintainable. The parameter configuration has also been included in the chill_doc_store configuration array for a unified approach.
This commit is contained in:
@@ -32,6 +32,8 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setParameter('chill_doc_store', $config);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('services/media.yaml');
|
||||
@@ -94,7 +96,6 @@ class ChillDocStoreExtension extends Extension implements PrependExtensionInterf
|
||||
'routing' => [
|
||||
'resources' => [
|
||||
'@ChillDocStoreBundle/config/routes.yaml',
|
||||
'@ChampsLibresAsyncUploaderBundle/config/routes.yaml',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
@@ -24,11 +25,68 @@ class Configuration implements ConfigurationInterface
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_doc_store');
|
||||
/** @var ArrayNodeDefinition $rootNode */
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
||||
// Here you should define the parameters that are allowed to
|
||||
// configure your bundle. See the documentation linked above for
|
||||
// more information on that topic.
|
||||
/* @phpstan-ignore-next-line As there are inconsistencies in return types, but the code works... */
|
||||
$rootNode->children()
|
||||
// openstack node
|
||||
->arrayNode('openstack')
|
||||
->info('parameters to authenticate and generate temp url against the openstack object storage service')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
// openstack.temp_url
|
||||
->arrayNode('temp_url')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
// openstack.temp_url.temp_url_key
|
||||
->scalarNode('temp_url_key')
|
||||
->isRequired()->cannotBeEmpty()
|
||||
->info('the temp url key')
|
||||
->end()
|
||||
|
||||
->scalarNode('temp_url_base_path')
|
||||
->isRequired()->cannotBeEmpty()
|
||||
->info('the base path to add **before** the path to media. Must contains the container')
|
||||
->end()
|
||||
|
||||
->scalarNode('container')
|
||||
->info('the container name')
|
||||
->isRequired()->cannotBeEmpty()
|
||||
->end()
|
||||
|
||||
->integerNode('max_post_file_size')
|
||||
->defaultValue(15_000_000)
|
||||
->info('Maximum size of the posted file, in bytes')
|
||||
->end()
|
||||
|
||||
->integerNode('max_post_file_count')
|
||||
->defaultValue(1)
|
||||
->info('Maximum number of files which may be posted at once using a POST operation using async upload')
|
||||
->end()
|
||||
|
||||
->integerNode('max_expires_delay')
|
||||
->defaultValue(180)
|
||||
->info('the maximum of seconds a cryptographic signature '
|
||||
.'will be valid for submitting a file. This should be '
|
||||
.'short, to avoid uploading multiple files')
|
||||
->end()
|
||||
|
||||
->integerNode('max_submit_delay')
|
||||
->defaultValue(3600)
|
||||
->info('the maximum of seconds between the upload of a file and '
|
||||
.'a the submission of the form. This delay will also prevent '
|
||||
.'the check of persistence of uploaded file. Should be long '
|
||||
.'enough for keeping user-friendly forms')
|
||||
->end()
|
||||
|
||||
->end() // end of children 's temp_url
|
||||
->end() // end array temp_url
|
||||
|
||||
->end() // end of children's openstack
|
||||
->end() // end of openstack
|
||||
->end() // end of root's children
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
Reference in New Issue
Block a user