mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 12:33:49 +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:
@@ -18,6 +18,7 @@ use Chill\DocStoreBundle\AsyncUpload\SignedUrlPost;
|
||||
use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
@@ -27,17 +28,28 @@ final readonly class TempUrlOpenstackGenerator implements TempUrlGeneratorInterf
|
||||
{
|
||||
private const CHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
private string $base_url;
|
||||
private string $key;
|
||||
private int $max_expire_delay;
|
||||
private int $max_submit_delay;
|
||||
private int $max_post_file_size;
|
||||
private int $max_file_count;
|
||||
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
private EventDispatcherInterface $event_dispatcher,
|
||||
private ClockInterface $clock,
|
||||
private string $base_url,
|
||||
private string $key,
|
||||
private int $max_expire_delay,
|
||||
private int $max_submit_delay,
|
||||
private int $max_post_file_size,
|
||||
private int $max_file_count = 1
|
||||
) {}
|
||||
ParameterBagInterface $parameterBag,
|
||||
) {
|
||||
$config = $parameterBag->get('chill_doc_store')['openstack']['temp_url'];
|
||||
|
||||
$this->key = $config['temp_url_key'];
|
||||
$this->base_url = $config['temp_url_base_path'];
|
||||
$this->max_expire_delay = $config['max_expires_delay'];
|
||||
$this->max_submit_delay = $config['max_submit_delay'];
|
||||
$this->max_post_file_size = $config['max_post_file_size'];
|
||||
$this->max_file_count = $config['max_post_file_count'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TempUrlGeneratorException
|
||||
@@ -115,7 +127,7 @@ final readonly class TempUrlOpenstackGenerator implements TempUrlGeneratorInterf
|
||||
];
|
||||
$url = $url.'?'.\http_build_query($args);
|
||||
|
||||
$signature = new SignedUrl($method, $url, $expires);
|
||||
$signature = new SignedUrl(strtoupper($method), $url, $expires);
|
||||
|
||||
$this->event_dispatcher->dispatch(
|
||||
new TempUrlGenerateEvent($signature)
|
||||
|
Reference in New Issue
Block a user