2121class ConfigOptionsList implements ConfigOptionsListInterface
2222{
2323 /**
24- * Input key for the option
25- */
26- private const INPUT_KEY_SALT ='id_salt ' ;
27-
28- /**
29- * Path to the values in the deployment config
24+ * @var Random
3025 */
31- private const CONFIG_PATH_SALT = ' cache/graphql/id_salt ' ;
26+ private $ random ;
3227
3328 /**
34- * @var Random
29+ * Deployment configuration
30+ *
31+ * @var DeploymentConfig
3532 */
36- private $ random ;
33+ private $ deploymentConfig ;
3734
3835 /**
3936 * @param Random $random
37+ * @param DeploymentConfig $deploymentConfig
4038 */
41- public function __construct (Random $ random )
42- {
39+ public function __construct (
40+ Random $ random ,
41+ DeploymentConfig $ deploymentConfig
42+ ) {
4343 $ this ->random = $ random ;
44+ $ this ->deploymentConfig = $ deploymentConfig ;
4445 }
4546
4647 /**
@@ -50,9 +51,9 @@ public function getOptions(): array
5051 {
5152 return [
5253 new TextConfigOption (
53- self ::INPUT_KEY_SALT ,
54+ ConfigOptionsListConstants ::INPUT_KEY_SALT ,
5455 TextConfigOption::FRONTEND_WIZARD_TEXT ,
55- self ::CONFIG_PATH_SALT ,
56+ ConfigOptionsListConstants ::CONFIG_PATH_SALT ,
5657 'GraphQl Salt '
5758 ),
5859 ];
@@ -64,11 +65,18 @@ public function getOptions(): array
6465 */
6566 public function createConfig (array $ data , DeploymentConfig $ deploymentConfig )
6667 {
68+ $ currentIdSalt = $ this ->deploymentConfig ->get (ConfigOptionsListConstants::CONFIG_PATH_SALT );
69+
6770 $ configData = new ConfigData (ConfigFilePool::APP_ENV );
6871
69- if (!$ this ->isDataEmpty ($ data , self ::INPUT_KEY_SALT )) {
70- $ salt = $ this ->random ->getRandomString (ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE );
71- $ configData ->set (self ::CONFIG_PATH_SALT , $ salt );
72+ // Use given salt if set, else use current
73+ $ id_salt = $ data [ConfigOptionsListConstants::INPUT_KEY_SALT ] ?? $ currentIdSalt ;
74+
75+ // If there is no id_salt given or currently set, generate a new one
76+ $ id_salt = $ id_salt ?? $ this ->random ->getRandomString (ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE );
77+
78+ if (!$ this ->isDataEmpty ($ data , ConfigOptionsListConstants::INPUT_KEY_SALT )) {
79+ $ configData ->set (ConfigOptionsListConstants::CONFIG_PATH_SALT , $ id_salt );
7280 }
7381
7482 return [$ configData ];
0 commit comments