|
15 | 15 |
|
16 | 16 | use Symfony\Component\Filesystem\Filesystem; |
17 | 17 | use Symfony\Component\Filesystem\Path; |
18 | | -use Symfony\UX\Toolkit\Asset\Component; |
19 | | -use Symfony\UX\Toolkit\File\File; |
20 | 18 | use Symfony\UX\Toolkit\Kit\Kit; |
21 | 19 | use Symfony\UX\Toolkit\Recipe\Recipe; |
22 | 20 |
|
@@ -49,25 +47,22 @@ private function handlePool(Pool $pool, Kit $kit, string $destinationPath, bool |
49 | 47 | { |
50 | 48 | $installedFiles = []; |
51 | 49 |
|
52 | | - foreach ($pool->getFiles() as $file) { |
53 | | - if ($this->installFile($kit, $file, $destinationPath, $force)) { |
54 | | - $installedFiles[] = $file; |
| 50 | + foreach ($pool->getFiles() as $recipeAbsolutePath => $files) { |
| 51 | + foreach ($files as $file) { |
| 52 | + $sourceAbsolutePathName = Path::join($recipeAbsolutePath, $file->sourceRelativePathName); |
| 53 | + $destinationAbsolutePathName = Path::join($destinationPath, $file->destinationRelativePathName); |
| 54 | + |
| 55 | + if ($this->copyFile($kit, $sourceAbsolutePathName, $destinationAbsolutePathName, $force)) { |
| 56 | + $installedFiles[] = $file; |
| 57 | + } |
55 | 58 | } |
56 | 59 | } |
57 | 60 |
|
58 | 61 | return new InstallationReport(newFiles: $installedFiles, suggestedPhpPackages: $pool->getPhpPackageDependencies()); |
59 | 62 | } |
60 | 63 |
|
61 | | - /** |
62 | | - * @param non-empty-string $destinationPath |
63 | | - */ |
64 | | - private function installFile(Kit $kit, File $file, string $destinationPath, bool $force): bool |
| 64 | + private function copyFile(Kit $kit, string $sourceAbsolutePathName, string $destinationAbsolutePathName, bool $force): bool |
65 | 65 | { |
66 | | - $sourceAbsolutePathName = Path::join($kit->absolutePath, $file->sourceRelativePathName); |
67 | | - $destinationAbsolutePathName = Path::join($destinationPath, $file->destinationRelativePathName); |
68 | | - |
69 | | - dump(source: $sourceAbsolutePathName, destination: $destinationAbsolutePathName, force: $force); |
70 | | - |
71 | 66 | if ($this->filesystem->exists($destinationAbsolutePathName) && !$force) { |
72 | 67 | if (!($this->askConfirmation)(\sprintf('File "%s" already exists. Do you want to overwrite it?', $destinationAbsolutePathName))) { |
73 | 68 | return false; |
|
0 commit comments