- public function __construct(FileLocator $locator, PackageInterface $package, $config, $tag, $output, $filters) {
- //Save locator
- $this->locator = $locator;
-
- //Save assets package
- $this->package = $package;
-
- //Set name
- $this->name = $config['name'];
-
- //Set scheme
- $this->scheme = $config['scheme'];
-
- //Set timeout
- $this->timeout = $config['timeout'];
-
- //Set agent
- $this->agent = $config['agent'];
-
- //Set redirect
- $this->redirect = $config['redirect'];
-
- //Set tag
- $this->tag = $tag;
-
- //Set output
- $this->output = $output;
-
- //Set filters
- $this->filters = $filters;
+ public function __construct(protected FileLocator $locator, protected PackageInterface $package, protected string $token, protected string $tag, protected string $output, protected array $filters) {
+ //Set ctx
+ $this->ctx = stream_context_create(
+ [
+ 'http' => [
+ #'header' => ['Referer: https://www.openstreetmap.org/'],
+ 'max_redirects' => $_ENV['RAPSYSPACK_REDIRECT'] ?? 20,
+ 'timeout' => $_ENV['RAPSYSPACK_TIMEOUT'] ?? (int)ini_get('default_socket_timeout') ?: 60,
+ 'user_agent' => $_ENV['RAPSYSPACK_AGENT'] ?? (($agent = ini_get('user_agent')) !== false && $agent !== "" ? (string)$agent : RapsysPackBundle::getAlias().'/'.RapsysPackBundle::getVersion())
+ ]
+ ]
+ );