@@ -111,34 +111,14 @@ public static function shouldConfigureDockerRecipe(Composer $composer, IOInterfa
111
111
return false ;
112
112
}
113
113
114
- $ warning = $ io ->isInteractive () ? 'WARNING ' : 'IGNORING ' ;
115
- $ io ->writeError (sprintf (' - <warning> %s </> %s ' , $ warning , $ recipe ->getFormattedOrigin ()));
116
- $ question = ' The recipe for this package contains some Docker configuration.
117
-
118
- This may create/update <comment>docker-compose.yml</comment> or update <comment>Dockerfile</comment> (if it exists).
119
-
120
- Do you want to include Docker configuration from recipes?
121
- [<comment>y</>] Yes
122
- [<comment>n</>] No
123
- [<comment>p</>] Yes permanently, never ask again for this project
124
- [<comment>x</>] No permanently, never ask again for this project
125
- (defaults to <comment>y</>): ' ;
126
- $ answer = $ io ->askAndValidate (
127
- $ question ,
128
- function ($ value ) {
129
- if (null === $ value ) {
130
- return 'y ' ;
131
- }
132
- $ value = strtolower ($ value [0 ]);
133
- if (!\in_array ($ value , ['y ' , 'n ' , 'p ' , 'x ' ], true )) {
134
- throw new \InvalidArgumentException ('Invalid choice. ' );
135
- }
114
+ if (!isset ($ _SERVER ['SYMFONY_DOCKER ' ])) {
115
+ $ answer = self ::askDockerSupport ($ io , $ recipe );
116
+ } elseif (filter_var ($ _SERVER ['SYMFONY_DOCKER ' ], \FILTER_VALIDATE_BOOLEAN )) {
117
+ $ answer = 'p ' ;
118
+ } else {
119
+ $ answer = 'x ' ;
120
+ }
136
121
137
- return $ value ;
138
- },
139
- null ,
140
- 'y '
141
- );
142
122
if ('n ' === $ answer ) {
143
123
self ::$ configureDockerRecipes = false ;
144
124
@@ -368,4 +348,37 @@ private function getContentsAfterApplyingRecipe(string $rootDir, Recipe $recipe,
368
348
369
349
return $ updatedContents ;
370
350
}
351
+
352
+ private static function askDockerSupport (IOInterface $ io , Recipe $ recipe ): string
353
+ {
354
+ $ warning = $ io ->isInteractive () ? 'WARNING ' : 'IGNORING ' ;
355
+ $ io ->writeError (sprintf (' - <warning> %s </> %s ' , $ warning , $ recipe ->getFormattedOrigin ()));
356
+ $ question = ' The recipe for this package contains some Docker configuration.
357
+
358
+ This may create/update <comment>docker-compose.yml</comment> or update <comment>Dockerfile</comment> (if it exists).
359
+
360
+ Do you want to include Docker configuration from recipes?
361
+ [<comment>y</>] Yes
362
+ [<comment>n</>] No
363
+ [<comment>p</>] Yes permanently, never ask again for this project
364
+ [<comment>x</>] No permanently, never ask again for this project
365
+ (defaults to <comment>y</>): ' ;
366
+
367
+ return $ io ->askAndValidate (
368
+ $ question ,
369
+ function ($ value ) {
370
+ if (null === $ value ) {
371
+ return 'y ' ;
372
+ }
373
+ $ value = strtolower ($ value [0 ]);
374
+ if (!\in_array ($ value , ['y ' , 'n ' , 'p ' , 'x ' ], true )) {
375
+ throw new \InvalidArgumentException ('Invalid choice. ' );
376
+ }
377
+
378
+ return $ value ;
379
+ },
380
+ null ,
381
+ 'y '
382
+ );
383
+ }
371
384
}
0 commit comments