1 | <?php |
||
23 | final class RenderableFilesProcessor |
||
24 | { |
||
25 | /** |
||
26 | * @var FileFactory |
||
27 | */ |
||
28 | private $fileFactory; |
||
29 | |||
30 | /** |
||
31 | * @var RouteDecorator |
||
32 | */ |
||
33 | private $routeDecorator; |
||
34 | |||
35 | /** |
||
36 | * @var ConfigurationDecorator |
||
37 | */ |
||
38 | private $configurationDecorator; |
||
39 | |||
40 | /** |
||
41 | * @var MarkdownDecorator |
||
42 | */ |
||
43 | private $markdownDecorator; |
||
44 | /** |
||
45 | * @var LatteDecorator |
||
46 | */ |
||
47 | private $latteDecorator; |
||
48 | |||
49 | /** |
||
50 | * @var FileSystemWriter |
||
51 | */ |
||
52 | private $fileSystemWriter; |
||
53 | |||
54 | /** |
||
55 | * @var Configuration |
||
56 | */ |
||
57 | private $configuration; |
||
58 | |||
59 | 6 | public function __construct( |
|
76 | |||
77 | /** |
||
78 | * @param SplFileInfo[] $fileInfos |
||
79 | */ |
||
80 | 3 | public function processFiles(array $fileInfos) |
|
81 | { |
||
82 | 3 | if (! count($fileInfos)) { |
|
83 | 1 | return; |
|
84 | } |
||
85 | |||
86 | 3 | $files = $this->createFileObjectsFromFileInfos($fileInfos); |
|
87 | |||
88 | 3 | $this->setPostsToConfiguration($files); |
|
89 | 3 | $this->setRoutesToFiles($files); |
|
90 | |||
91 | 3 | $this->setFileConfigurationToFile($files); |
|
92 | 3 | $this->formatFileContentFromMarkdownToHtml($files); |
|
93 | 3 | $this->formatFileContentFromLatteToHtml($files); |
|
94 | |||
95 | 3 | $this->fileSystemWriter->copyRenderableFiles($files); |
|
96 | 3 | } |
|
97 | |||
98 | /** |
||
99 | * @param array $fileInfos |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | 3 | private function createFileObjectsFromFileInfos(array $fileInfos):array |
|
112 | |||
113 | /** |
||
114 | * @param File[] $files |
||
115 | */ |
||
116 | 3 | private function setPostsToConfiguration(array $files) |
|
117 | { |
||
118 | 3 | if (reset($files) instanceof PostFile) { |
|
119 | 2 | $this->configuration->addGlobalVarialbe('posts', $files); |
|
120 | } |
||
121 | 3 | } |
|
122 | |||
123 | /** |
||
124 | * @param File[] $files |
||
125 | */ |
||
126 | 3 | private function setRoutesToFiles(array $files) |
|
132 | |||
133 | /** |
||
134 | * @param File[] $files |
||
135 | */ |
||
136 | 3 | private function setFileConfigurationToFile(array $files) |
|
142 | |||
143 | /** |
||
144 | * @param File[] $files |
||
145 | */ |
||
146 | 3 | private function formatFileContentFromMarkdownToHtml(array $files) |
|
152 | |||
153 | /** |
||
154 | * @param File[] $files |
||
155 | */ |
||
156 | 3 | private function formatFileContentFromLatteToHtml(array $files) |
|
162 | } |
||
163 |