@@ -65,7 +65,7 @@ class Flex implements PluginInterface, EventSubscriberInterface
65
65
private $ config ;
66
66
private $ options ;
67
67
private $ configurator ;
68
- private $ downloader ;
68
+ private RecipeProviderInterface $ recipeProvider ;
69
69
70
70
/**
71
71
* @var Installer
@@ -112,10 +112,14 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
112
112
113
113
$ rfs = Factory::createHttpDownloader ($ this ->io , $ this ->config );
114
114
115
- $ this ->downloader = $ downloader = new Downloader ($ composer , $ io , $ rfs );
115
+ $ this ->recipeProvider = new CompositeRecipeProvider (
116
+ [
117
+ new Downloader ($ composer , $ io , $ rfs ),
118
+ new LocalRecipeProvider ($ composer ),
119
+ ]);
116
120
117
121
if ($ symfonyRequire ) {
118
- $ this ->filter = new PackageFilter ($ io , $ symfonyRequire , $ this ->downloader );
122
+ $ this ->filter = new PackageFilter ($ io , $ symfonyRequire , $ this ->recipeProvider );
119
123
}
120
124
121
125
$ composerFile = Factory::getComposerFile ();
@@ -134,7 +138,7 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
134
138
}
135
139
}
136
140
if ($ disable ) {
137
- $ downloader ->disable ();
141
+ $ this -> recipeProvider ->disable ();
138
142
}
139
143
140
144
$ backtrace = $ this ->configureInstaller ();
@@ -153,7 +157,7 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
153
157
$ input = $ trace ['args ' ][0 ];
154
158
$ app = $ trace ['object ' ];
155
159
156
- $ resolver = new PackageResolver ($ this ->downloader );
160
+ $ resolver = new PackageResolver ($ this ->recipeProvider );
157
161
158
162
try {
159
163
$ command = $ input ->getFirstArgument ();
@@ -186,7 +190,7 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
186
190
187
191
$ app ->add (new Command \RecipesCommand ($ this , $ this ->lock , $ rfs ));
188
192
$ app ->add (new Command \InstallRecipesCommand ($ this , $ this ->options ->get ('root-dir ' ), $ this ->options ->get ('runtime ' )['dotenv_path ' ] ?? '.env ' ));
189
- $ app ->add (new Command \UpdateRecipesCommand ($ this , $ this ->downloader , $ rfs , $ this ->configurator , $ this ->options ->get ('root-dir ' )));
193
+ $ app ->add (new Command \UpdateRecipesCommand ($ this , $ this ->recipeProvider , $ rfs , $ this ->configurator , $ this ->options ->get ('root-dir ' )));
190
194
$ app ->add (new Command \DumpEnvCommand ($ this ->config , $ this ->options ));
191
195
192
196
break ;
@@ -215,7 +219,7 @@ public function configureInstaller()
215
219
}
216
220
217
221
if (isset ($ trace ['object ' ]) && $ trace ['object ' ] instanceof GlobalCommand) {
218
- $ this ->downloader ->disable ();
222
+ $ this ->recipeProvider ->disable ();
219
223
}
220
224
}
221
225
@@ -224,7 +228,7 @@ public function configureInstaller()
224
228
225
229
public function configureProject (Event $ event )
226
230
{
227
- if (!$ this ->downloader ->isEnabled ()) {
231
+ if (!$ this ->recipeProvider ->isEnabled ()) {
228
232
$ this ->io ->writeError ('<warning>Project configuration is disabled: "symfony/flex" not found in the root composer.json</> ' );
229
233
230
234
return ;
@@ -312,7 +316,7 @@ public function update(Event $event, $operations = [])
312
316
$ manipulator = new JsonManipulator ($ contents );
313
317
$ sortPackages = $ this ->composer ->getConfig ()->get ('sort-packages ' );
314
318
$ symfonyVersion = $ json ['extra ' ]['symfony ' ]['require ' ] ?? null ;
315
- $ versions = $ symfonyVersion ? $ this ->downloader ->getVersions () : null ;
319
+ $ versions = $ symfonyVersion ? $ this ->recipeProvider ->getVersions () : null ;
316
320
foreach (['require ' , 'require-dev ' ] as $ type ) {
317
321
if (!isset ($ json ['flex- ' .$ type ])) {
318
322
continue ;
@@ -363,15 +367,15 @@ public function install(Event $event)
363
367
$ this ->finish ($ rootDir );
364
368
}
365
369
366
- if ($ this ->downloader ->isEnabled ()) {
370
+ if ($ this ->recipeProvider ->isEnabled ()) {
367
371
$ this ->io ->writeError ('Run <comment>composer recipes</> at any time to see the status of your Symfony recipes. ' );
368
372
$ this ->io ->writeError ('' );
369
373
}
370
374
371
375
return ;
372
376
}
373
377
374
- $ this ->io ->writeError (sprintf ('<info>Symfony operations: %d recipe%s (%s)</> ' , \count ($ recipes ), \count ($ recipes ) > 1 ? 's ' : '' , $ this ->downloader ->getSessionId ()));
378
+ $ this ->io ->writeError (sprintf ('<info>Symfony operations: %d recipe%s (%s)</> ' , \count ($ recipes ), \count ($ recipes ) > 1 ? 's ' : '' , $ this ->recipeProvider ->getSessionId ()));
375
379
$ installContribs = $ this ->composer ->getPackage ()->getExtra ()['symfony ' ]['allow-contrib ' ] ?? false ;
376
380
$ manifest = null ;
377
381
$ originalComposerJsonHash = $ this ->getComposerJsonHash ();
@@ -527,13 +531,13 @@ public function executeAutoScripts(Event $event)
527
531
*/
528
532
public function fetchRecipes (array $ operations , bool $ reset ): array
529
533
{
530
- if (!$ this ->downloader ->isEnabled ()) {
534
+ if (!$ this ->recipeProvider ->isEnabled ()) {
531
535
$ this ->io ->writeError ('<warning>Symfony recipes are disabled: "symfony/flex" not found in the root composer.json</> ' );
532
536
533
537
return [];
534
538
}
535
539
$ devPackages = null ;
536
- $ data = $ this ->downloader ->getRecipes ($ operations );
540
+ $ data = $ this ->recipeProvider ->getRecipes ($ operations );
537
541
$ manifests = $ data ['manifests ' ] ?? [];
538
542
$ locks = $ data ['locks ' ] ?? [];
539
543
// symfony/flex recipes should always be applied first
@@ -562,8 +566,8 @@ public function fetchRecipes(array $operations, bool $reset): array
562
566
}
563
567
564
568
while ($ this ->doesRecipeConflict ($ manifests [$ name ] ?? [], $ operation )) {
565
- $ this ->downloader ->removeRecipeFromIndex ($ name , $ manifests [$ name ]['version ' ]);
566
- $ newData = $ this ->downloader ->getRecipes ([$ operation ]);
569
+ $ this ->recipeProvider ->removeRecipeFromIndex ($ name , $ manifests [$ name ]['version ' ]);
570
+ $ newData = $ this ->recipeProvider ->getRecipes ([$ operation ]);
567
571
$ newManifests = $ newData ['manifests ' ] ?? [];
568
572
569
573
if (!isset ($ newManifests [$ name ])) {
@@ -751,7 +755,7 @@ private function unpack(Event $event)
751
755
}
752
756
}
753
757
754
- $ unpacker = new Unpacker ($ this ->composer , new PackageResolver ($ this ->downloader ), $ this ->dryRun );
758
+ $ unpacker = new Unpacker ($ this ->composer , new PackageResolver ($ this ->recipeProvider ), $ this ->dryRun );
755
759
$ result = $ unpacker ->unpack ($ unpackOp );
756
760
757
761
if (!$ result ->getUnpacked ()) {
0 commit comments