|
29 | 29 | class Downloader
|
30 | 30 | {
|
31 | 31 | private const DEFAULT_ENDPOINTS = [
|
32 |
| - 'https://api.github.com/repos/symfony/recipes/contents/index.json?ref=flex/main' => [], |
33 |
| - 'https://api.github.com/repos/symfony/recipes-contrib/contents/index.json?ref=flex/main' => [], |
| 32 | + 'https://api.github.com/repos/symfony/recipes/contents/index.json?ref=flex/main', |
| 33 | + 'https://api.github.com/repos/symfony/recipes-contrib/contents/index.json?ref=flex/main', |
34 | 34 | ];
|
35 | 35 | private const MAX_LENGTH = 1000;
|
36 | 36 |
|
@@ -63,25 +63,29 @@ public function __construct(Composer $composer, IoInterface $io, $rfs)
|
63 | 63 | $this->endpoints = null;
|
64 | 64 | $this->legacyEndpoint = 'https://flex.symfony.com';
|
65 | 65 | }
|
66 |
| - } elseif (\is_array($endpoint) || false !== strpos($endpoint, '.json')) { |
67 |
| - $this->endpoints = array_fill_keys((array) $endpoint, []); |
| 66 | + } elseif (\is_array($endpoint) || false !== strpos($endpoint, '.json') || 'flex://defaults' === $endpoint) { |
| 67 | + $this->endpoints = array_values((array) $endpoint); |
68 | 68 | } else {
|
69 | 69 | $this->legacyEndpoint = rtrim($endpoint, '/');
|
70 | 70 | }
|
71 | 71 |
|
72 | 72 | if (false === $endpoint = getenv('SYMFONY_ENDPOINT')) {
|
73 | 73 | // no-op
|
74 |
| - } elseif (false !== strpos($endpoint, '.json')) { |
| 74 | + } elseif (false !== strpos($endpoint, '.json') || 'flex://defaults' === $endpoint) { |
75 | 75 | $this->endpoints ?? $this->endpoints = self::DEFAULT_ENDPOINTS;
|
76 |
| - $this->endpoints = [$endpoint => []] + $this->endpoints; |
| 76 | + array_unshift($this->endpoints, $endpoint); |
77 | 77 | $this->legacyEndpoint = null;
|
78 | 78 | } else {
|
79 | 79 | $this->endpoints = null;
|
80 | 80 | $this->legacyEndpoint = rtrim($endpoint, '/');
|
81 | 81 | }
|
82 | 82 |
|
83 |
| - if (null !== $this->endpoints && false !== $i = array_search('flex://defaults', $this->endpoints, true)) { |
84 |
| - array_splice($this->endpoints, $i, 1, self::DEFAULT_ENDPOINTS); |
| 83 | + if (null !== $this->endpoints) { |
| 84 | + if (false !== $i = array_search('flex://defaults', $this->endpoints, true)) { |
| 85 | + array_splice($this->endpoints, $i, 1, self::DEFAULT_ENDPOINTS); |
| 86 | + } |
| 87 | + |
| 88 | + $this->endpoints = array_fill_keys($this->endpoints, []); |
85 | 89 | }
|
86 | 90 |
|
87 | 91 | $this->io = $io;
|
|
0 commit comments