Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
TransfersMediaAssetsForBuildCommands | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
transferMediaAssets | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Hyde\Framework\Concerns\Internal; |
4 | |
5 | use Hyde\Framework\Concerns\InteractsWithDirectories; |
6 | use Hyde\Framework\Hyde; |
7 | use Hyde\Framework\Services\CollectionService; |
8 | |
9 | /** |
10 | * Transfer all media assets to the build directory. |
11 | * |
12 | * @see \Hyde\Framework\Commands\HydeBuildStaticSiteCommand |
13 | * @see \Hyde\Framework\Commands\HydeRebuildStaticSiteCommand |
14 | * |
15 | * @internal |
16 | */ |
17 | trait TransfersMediaAssetsForBuildCommands |
18 | { |
19 | use BuildActionRunner; |
20 | use InteractsWithDirectories; |
21 | |
22 | /** @internal */ |
23 | protected function transferMediaAssets(): void |
24 | { |
25 | $this->needsDirectory(Hyde::getSiteOutputPath('media')); |
26 | |
27 | $collection = CollectionService::getMediaAssetFiles(); |
28 | if ($this->canRunBuildAction($collection, 'Media Assets', 'Transferring')) { |
29 | $this->withProgressBar( |
30 | $collection, |
31 | function ($filepath) { |
32 | copy($filepath, Hyde::getSiteOutputPath('media/'.basename($filepath))); |
33 | } |
34 | ); |
35 | $this->newLine(2); |
36 | } |
37 | } |
38 | } |