]> Raphaël G. Git Repositories - packbundle/commitdiff
Move stream context array in context parameter
authorRaphaël Gertz <git@rapsys.eu>
Sun, 8 Dec 2024 05:27:25 +0000 (06:27 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Sun, 8 Dec 2024 05:27:25 +0000 (06:27 +0100)
Controller.php
DependencyInjection/Configuration.php

index 148d37c15cf6aebbd41cff1315913acef1b2c4f6..77a3e14e5a10d1c4d1e2c64e9c89f062e96766a1 100644 (file)
@@ -63,15 +63,7 @@ class Controller extends AbstractController implements ServiceSubscriberInterfac
                $this->config = $container->getParameter($this->alias = RapsysPackBundle::getAlias());
 
                //Set ctx
-               $this->ctx = stream_context_create(
-                       [
-                               'http' => [
-                                       'max_redirects' => $_ENV['RAPSYSPACK_REDIRECT'] ?? 20,
-                                       'timeout' => $_ENV['RAPSYSPACK_TIMEOUT'] ?? (($timeout = ini_get('default_socket_timeout')) !== false && $timeout !== '' ? (float)$timeout : 60),
-                                       'user_agent' => $_ENV['RAPSYSPACK_AGENT'] ?? (($agent = ini_get('user_agent')) !== false && $agent !== '' ? (string)$agent : $this->alias.'/'.($this->version = RapsysPackBundle::getVersion()))
-                               ]
-                       ]
-               );
+               $this->ctx = stream_context_create($this->config['context']);
        }
 
        /**
index 8f3beb23ff5f3f9cfad02b678bb80785838b023a..af0c83ed6da73950e6c2026dc3444589ffd94786 100644 (file)
@@ -50,6 +50,13 @@ class Configuration implements ConfigurationInterface {
                                'thickness' => 2,
                                'width' => 192
                        ],
+                       'context' => [
+                               'http' => [
+                                       'max_redirects' => $_ENV['RAPSYSPACK_REDIRECT'] ?? 20,
+                                       'timeout' => $_ENV['RAPSYSPACK_TIMEOUT'] ?? (($timeout = ini_get('default_socket_timeout')) !== false && $timeout !== '' ? (float)$timeout : 60),
+                                       'user_agent' => $_ENV['RAPSYSPACK_AGENT'] ?? (($agent = ini_get('user_agent')) !== false && $agent !== '' ? (string)$agent : $alias.'/'.($version = RapsysPackBundle::getVersion()))
+                               ]
+                       ],
                        'facebook' => [
                                'align' => 'center',
                                'fill' => 'white',
@@ -193,6 +200,18 @@ class Configuration implements ConfigurationInterface {
                                                        ->scalarNode('width')->cannotBeEmpty()->defaultValue($defaults['captcha']['width'])->end()
                                                ->end()
                                        ->end()
+                                       ->arrayNode('context')
+                                               ->addDefaultsIfNotSet()
+                                               ->children()
+                                                       ->arrayNode('http')
+                                                       ->addDefaultsIfNotSet()
+                                                       ->children()
+                                                               ->scalarNode('max_redirects')->defaultValue($defaults['captcha']['max_redirects'])->end()
+                                                               ->scalarNode('timeout')->defaultValue($defaults['captcha']['timeout'])->end()
+                                                               ->scalarNode('user_agent')->cannotBeEmpty()->defaultValue($defaults['captcha']['user_agent'])->end()
+                                                       ->end()
+                                               ->end()
+                                       ->end()
                                        ->arrayNode('facebook')
                                                ->addDefaultsIfNotSet()
                                                ->children()