1 | <?php |
||
18 | class Finder extends SymfonyFinder implements FinderInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var \Symfony\Component\Console\Output\ConsoleOutput |
||
22 | */ |
||
23 | protected $console; |
||
24 | |||
25 | /** |
||
26 | * @param ConsoleOutput $console |
||
27 | */ |
||
28 | public function __construct(ConsoleOutput $console) |
||
34 | |||
35 | /** |
||
36 | * return a collection of arrays of assets paths found |
||
37 | * in the included directories, except all ignored |
||
38 | * (directories, patterns, extensions and files). |
||
39 | * |
||
40 | * @param AssetInterface $asset_holder |
||
41 | * |
||
42 | * @return Collection |
||
43 | */ |
||
44 | public function read(AssetInterface $asset_holder) |
||
45 | { |
||
46 | /* |
||
47 | * add the included directories and files |
||
48 | */ |
||
49 | $this->includeThis($asset_holder); |
||
50 | /* |
||
51 | * exclude the ignored directories and files |
||
52 | */ |
||
53 | $this->excludeThis($asset_holder); |
||
54 | |||
55 | // user terminal message |
||
56 | $this->console->writeln('<fg=yellow>Files to upload:</fg=yellow>'); |
||
57 | |||
58 | // get all allowed 'for upload' files objects (assets) and store them in an array |
||
59 | $assets = []; |
||
60 | foreach ($this->files() as $file) { |
||
61 | // user terminal message |
||
62 | $this->console->writeln('<fg=cyan>'.'Path: '.$file->getRealpath().'</fg=cyan>'); |
||
63 | |||
64 | $assets[] = $file; |
||
65 | } |
||
66 | |||
67 | return new Collection($assets); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Add the included directories and files. |
||
72 | * |
||
73 | * @param AssetInterface $asset_holder |
||
74 | */ |
||
75 | private function includeThis(AssetInterface $asset_holder) |
||
94 | |||
95 | /** |
||
96 | * exclude the ignored directories and files. |
||
97 | * |
||
98 | * @param AssetInterface $asset_holder |
||
99 | */ |
||
100 | private function excludeThis(AssetInterface $asset_holder) |
||
123 | } |
||
124 |