@@ -20,9 +20,11 @@ |
||
20 | 20 | */ |
21 | 21 | public static function modifiedAfter(DateTime $time): Closure |
22 | 22 | { |
23 | - return function ($file) use ($time) { |
|
23 | + return function ($file) use ($time) |
|
24 | + { |
|
24 | 25 | /** @var File|Folder $file */ |
25 | - if ($file instanceof Folder) { |
|
26 | + if ($file instanceof Folder) |
|
27 | + { |
|
26 | 28 | return true; |
27 | 29 | } |
28 | 30 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * |
25 | 25 | * @throws FileNotFoundException |
26 | 26 | */ |
27 | - public function __construct(protected string|FilesystemPath $rawPath) |
|
27 | + public function __construct(protected string | FilesystemPath $rawPath) |
|
28 | 28 | { |
29 | 29 | $realPath = fs::realpath($rawPath); |
30 | 30 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | { |
29 | 29 | $realPath = fs::realpath($rawPath); |
30 | 30 | |
31 | - if ($realPath === false) { |
|
31 | + if ($realPath === false) |
|
32 | + { |
|
32 | 33 | throw $this->buildNotFoundException(); |
33 | 34 | } |
34 | 35 | |
@@ -112,11 +113,13 @@ discard block |
||
112 | 113 | */ |
113 | 114 | protected function isSafeToRead(): void |
114 | 115 | { |
115 | - if (fs::isVFS($this->getAbsolutePath())) { |
|
116 | + if (fs::isVFS($this->getAbsolutePath())) |
|
117 | + { |
|
116 | 118 | return; |
117 | 119 | } |
118 | 120 | |
119 | - if (!str_starts_with($this->getAbsolutePath(), (string)Service::getWorkingDirectory())) { |
|
121 | + if (!str_starts_with($this->getAbsolutePath(), (string)Service::getWorkingDirectory())) |
|
122 | + { |
|
120 | 123 | throw $this->buildNotFoundException(); |
121 | 124 | } |
122 | 125 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return false|T |
225 | 225 | */ |
226 | - public function realpath(string|BaseFilesystemItem $path): false|string|BaseFilesystemItem |
|
226 | + public function realpath(string | BaseFilesystemItem $path): false | string | BaseFilesystemItem |
|
227 | 227 | { |
228 | 228 | return $this->isVFS($path) ? $path : realpath((string)$path); |
229 | 229 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * Check whether a given path is on the virtual filesystem. |
233 | 233 | */ |
234 | - public function isVFS(string|BaseFilesystemItem $path): bool |
|
234 | + public function isVFS(string | BaseFilesystemItem $path): bool |
|
235 | 235 | { |
236 | 236 | return str_starts_with((string)$path, 'vfs://'); |
237 | 237 | } |
@@ -25,11 +25,13 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function absolutePath($pathFragments): string |
27 | 27 | { |
28 | - if ($pathFragments instanceof FilesystemPath) { |
|
28 | + if ($pathFragments instanceof FilesystemPath) |
|
29 | + { |
|
29 | 30 | $pathFragments = (string)$pathFragments; |
30 | 31 | } |
31 | 32 | |
32 | - if ($this->isAbsolutePath($pathFragments)) { |
|
33 | + if ($this->isAbsolutePath($pathFragments)) |
|
34 | + { |
|
33 | 35 | return $pathFragments; |
34 | 36 | } |
35 | 37 | |
@@ -61,16 +63,20 @@ discard block |
||
61 | 63 | */ |
62 | 64 | public function copy($originFile, $targetFile, $overwriteNewerFiles = false): void |
63 | 65 | { |
64 | - if ($this->isDir($originFile)) { |
|
65 | - if (!$this->isDir($targetFile)) { |
|
66 | + if ($this->isDir($originFile)) |
|
67 | + { |
|
68 | + if (!$this->isDir($targetFile)) |
|
69 | + { |
|
66 | 70 | mkdir($targetFile, 0755, true); |
67 | 71 | } |
68 | 72 | |
69 | 73 | $dir = dir($originFile); |
70 | 74 | |
71 | - while (false !== $entry = $dir->read()) { |
|
75 | + while (false !== $entry = $dir->read()) |
|
76 | + { |
|
72 | 77 | // Skip pointers |
73 | - if ($entry == '.' || $entry == '..') { |
|
78 | + if ($entry == '.' || $entry == '..') |
|
79 | + { |
|
74 | 80 | continue; |
75 | 81 | } |
76 | 82 | |
@@ -78,7 +84,9 @@ discard block |
||
78 | 84 | } |
79 | 85 | |
80 | 86 | $dir->close(); |
81 | - } else { |
|
87 | + } |
|
88 | + else |
|
89 | + { |
|
82 | 90 | parent::copy($originFile, $targetFile, $overwriteNewerFiles); |
83 | 91 | } |
84 | 92 | } |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - protected function addFileToTracker(File &$file): void |
|
165 | + protected function addFileToTracker(File & $file): void |
|
166 | 166 | { |
167 | 167 | $this->trackedItemsFlattened[$file->getRelativeFilePath()] = &$file; |
168 | 168 | } |
169 | 169 | |
170 | - protected function delFileFromTracker(File &$file): void |
|
170 | + protected function delFileFromTracker(File & $file): void |
|
171 | 171 | { |
172 | 172 | unset($this->trackedItemsFlattened[$file->getRelativeFilePath()]); |
173 | 173 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @param null|string $namespace |
179 | 179 | */ |
180 | - protected function addObjectToTracker(ReadableDocument &$trackedItem, $namespace = null): void |
|
180 | + protected function addObjectToTracker(ReadableDocument & $trackedItem, $namespace = null): void |
|
181 | 181 | { |
182 | 182 | if ($namespace == null) { |
183 | 183 | $this->trackedItems[$trackedItem->getIndexName()] = &$trackedItem; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param null|string $namespace |
195 | 195 | */ |
196 | - protected function delObjectFromTracker(ReadableDocument &$trackedItem, $namespace = null): void |
|
196 | + protected function delObjectFromTracker(ReadableDocument & $trackedItem, $namespace = null): void |
|
197 | 197 | { |
198 | 198 | if ($namespace == null) { |
199 | 199 | unset($this->trackedItems[$trackedItem->getIndexName()]); |
@@ -96,7 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function getTracked($filePath): mixed |
98 | 98 | { |
99 | - if ($this->isTracked($filePath)) { |
|
99 | + if ($this->isTracked($filePath)) |
|
100 | + { |
|
100 | 101 | return $this->trackedItemsFlattened[(string)$filePath]; |
101 | 102 | } |
102 | 103 | |
@@ -125,8 +126,10 @@ discard block |
||
125 | 126 | */ |
126 | 127 | public function shouldBeTracked($filePath): bool |
127 | 128 | { |
128 | - foreach ($this->folderDefinitions as $folder) { |
|
129 | - if (str_starts_with($filePath, $folder)) { |
|
129 | + foreach ($this->folderDefinitions as $folder) |
|
130 | + { |
|
131 | + if (str_starts_with($filePath, $folder)) |
|
132 | + { |
|
130 | 133 | return true; |
131 | 134 | } |
132 | 135 | } |
@@ -157,7 +160,8 @@ discard block |
||
157 | 160 | */ |
158 | 161 | protected function declareTrackingNamespace($namespace): void |
159 | 162 | { |
160 | - if (!isset($this->trackedItems[$namespace])) { |
|
163 | + if (!isset($this->trackedItems[$namespace])) |
|
164 | + { |
|
161 | 165 | $this->trackedItems[$namespace] = []; |
162 | 166 | } |
163 | 167 | } |
@@ -179,9 +183,12 @@ discard block |
||
179 | 183 | */ |
180 | 184 | protected function addObjectToTracker(ReadableDocument &$trackedItem, $namespace = null): void |
181 | 185 | { |
182 | - if ($namespace == null) { |
|
186 | + if ($namespace == null) |
|
187 | + { |
|
183 | 188 | $this->trackedItems[$trackedItem->getIndexName()] = &$trackedItem; |
184 | - } else { |
|
189 | + } |
|
190 | + else |
|
191 | + { |
|
185 | 192 | $this->trackedItems[$namespace][$trackedItem->getIndexName()] = &$trackedItem; |
186 | 193 | } |
187 | 194 | |
@@ -195,9 +202,12 @@ discard block |
||
195 | 202 | */ |
196 | 203 | protected function delObjectFromTracker(ReadableDocument &$trackedItem, $namespace = null): void |
197 | 204 | { |
198 | - if ($namespace == null) { |
|
205 | + if ($namespace == null) |
|
206 | + { |
|
199 | 207 | unset($this->trackedItems[$trackedItem->getIndexName()]); |
200 | - } else { |
|
208 | + } |
|
209 | + else |
|
210 | + { |
|
201 | 211 | unset($this->trackedItems[$namespace][$trackedItem->getIndexName()]); |
202 | 212 | } |
203 | 213 | |
@@ -255,14 +265,16 @@ discard block |
||
255 | 265 | { |
256 | 266 | $this->watchedFolders[$def->folder->getAbsolutePath()] = $def; |
257 | 267 | |
258 | - if (empty($def->excludes)) { |
|
268 | + if (empty($def->excludes)) |
|
269 | + { |
|
259 | 270 | $def->excludes = self::$documentIgnoreList; |
260 | 271 | } |
261 | 272 | |
262 | 273 | $fileExplorer = FileExplorer::createFromDefinition($def); |
263 | 274 | $fileIterator = $fileExplorer->getFileIterator(); |
264 | 275 | |
265 | - foreach ($fileIterator as $file) { |
|
276 | + foreach ($fileIterator as $file) |
|
277 | + { |
|
266 | 278 | $this->handleTrackableItem($file, $options); |
267 | 279 | } |
268 | 280 | } |
@@ -298,18 +310,24 @@ discard block |
||
298 | 310 | $jailItems = []; |
299 | 311 | |
300 | 312 | /** @var CollectableItem|ReadableDocument $item */ |
301 | - foreach ($elements as &$item) { |
|
302 | - if ($item instanceof TemplateReadyDocument) { |
|
303 | - if (!Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS) && $item->isDraft()) { |
|
313 | + foreach ($elements as &$item) |
|
314 | + { |
|
315 | + if ($item instanceof TemplateReadyDocument) |
|
316 | + { |
|
317 | + if (!Service::hasRunTimeFlag(RuntimeStatus::USING_DRAFTS) && $item->isDraft()) |
|
318 | + { |
|
304 | 319 | continue; |
305 | 320 | } |
306 | 321 | } |
307 | 322 | |
308 | 323 | $keyName = ($name === null) ? $item->getRelativeFilePath() : $name($item); |
309 | 324 | |
310 | - if (empty($item->getNamespace())) { |
|
325 | + if (empty($item->getNamespace())) |
|
326 | + { |
|
311 | 327 | $jailItems[$keyName] = $item->createJail(); |
312 | - } else { |
|
328 | + } |
|
329 | + else |
|
330 | + { |
|
313 | 331 | $jailItems[$item->getNamespace()][$keyName] = $item->createJail(); |
314 | 332 | } |
315 | 333 | } |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function compileManager(): void |
40 | 40 | { |
41 | - if (!$this->configuration->hasDataItems()) { |
|
41 | + if (!$this->configuration->hasDataItems()) |
|
42 | + { |
|
42 | 43 | $this->logger->notice('No DataItems or Datasets detected... Ignoring.'); |
43 | 44 | |
44 | 45 | return; |
@@ -73,11 +74,13 @@ discard block |
||
73 | 74 | */ |
74 | 75 | public function parseDataItems($folders): void |
75 | 76 | { |
76 | - if ($folders === null) { |
|
77 | + if ($folders === null) |
|
78 | + { |
|
77 | 79 | return; |
78 | 80 | } |
79 | 81 | |
80 | - foreach ($folders as $folder) { |
|
82 | + foreach ($folders as $folder) |
|
83 | + { |
|
81 | 84 | $cls = new Folder($folder); |
82 | 85 | |
83 | 86 | $this->logger->debug('Scanning "{folder}" for data items...', [ |
@@ -101,7 +104,8 @@ discard block |
||
101 | 104 | */ |
102 | 105 | public function parseDataSets($dataSets): void |
103 | 106 | { |
104 | - if ($dataSets === null) { |
|
107 | + if ($dataSets === null) |
|
108 | + { |
|
105 | 109 | return; |
106 | 110 | } |
107 | 111 | |
@@ -113,7 +117,8 @@ discard block |
||
113 | 117 | * 'folder' => '(string) The folder where this collection has its ContentItems' |
114 | 118 | * ] |
115 | 119 | */ |
116 | - foreach ($dataSets as $dataSet) { |
|
120 | + foreach ($dataSets as $dataSet) |
|
121 | + { |
|
117 | 122 | $folder = new Folder($dataSet['folder']); |
118 | 123 | |
119 | 124 | $this->logger->debug('Scanning "{folder}" for the "{name}" dataset...', [ |
@@ -137,7 +142,8 @@ discard block |
||
137 | 142 | */ |
138 | 143 | protected function handleTrackableItem(File $filePath, array $options = []): mixed |
139 | 144 | { |
140 | - try { |
|
145 | + try |
|
146 | + { |
|
141 | 147 | $namespace = $options['namespace'] ?? null; |
142 | 148 | |
143 | 149 | $dataItem = new DataItem($filePath); |
@@ -151,12 +157,17 @@ discard block |
||
151 | 157 | $this->saveTrackerOptions($dataItem->getRelativeFilePath(), $options); |
152 | 158 | |
153 | 159 | return $dataItem->getRelativeFilePath(); |
154 | - } catch (DependencyMissingException $e) { |
|
155 | - if ($e->getDependency() === 'XML') { |
|
160 | + } |
|
161 | + catch (DependencyMissingException $e) |
|
162 | + { |
|
163 | + if ($e->getDependency() === 'XML') |
|
164 | + { |
|
156 | 165 | $this->logger->critical('XML support is not available in your PHP installation. For XML support, please install the appropriate package for your system:'); |
157 | 166 | $this->logger->critical(' e.g. php7.0-xml'); |
158 | 167 | } |
159 | - } catch (UnsupportedDataTypeException $e) { |
|
168 | + } |
|
169 | + catch (UnsupportedDataTypeException $e) |
|
170 | + { |
|
160 | 171 | $this->logger->warning('There is no function to handle {ext} file format.', [ |
161 | 172 | 'ext' => $e->getDataType(), |
162 | 173 | ]); |
@@ -179,7 +179,7 @@ |
||
179 | 179 | * |
180 | 180 | * @since 0.2.0 |
181 | 181 | */ |
182 | - public function trackNewPageView(BasePageView|DynamicPageView|RepeaterPageView|StaticPageView $pageView): void |
|
182 | + public function trackNewPageView(BasePageView | DynamicPageView | RepeaterPageView | StaticPageView $pageView): void |
|
183 | 183 | { |
184 | 184 | $namespace = $pageView->getType(); |
185 | 185 |
@@ -85,7 +85,8 @@ discard block |
||
85 | 85 | $preEvent = new PageManagerPreProcess($this); |
86 | 86 | $this->eventDispatcher->dispatch($preEvent, PageManagerPreProcess::NAME); |
87 | 87 | |
88 | - foreach ($pageViewFolders as $pageViewFolderName) { |
|
88 | + foreach ($pageViewFolders as $pageViewFolderName) |
|
89 | + { |
|
89 | 90 | $folder = new Folder($pageViewFolderName); |
90 | 91 | |
91 | 92 | $event = new PageViewDefinitionAdded($folder); |
@@ -149,7 +150,8 @@ discard block |
||
149 | 150 | { |
150 | 151 | $jailedObjects = []; |
151 | 152 | |
152 | - foreach ($this->staticPages as $key => $value) { |
|
153 | + foreach ($this->staticPages as $key => $value) |
|
154 | + { |
|
153 | 155 | $jailedObjects[$key] = $value->createJail(); |
154 | 156 | } |
155 | 157 | |
@@ -163,7 +165,8 @@ discard block |
||
163 | 165 | { |
164 | 166 | $jailedObjects = []; |
165 | 167 | |
166 | - foreach ($this->repeaterPages as $key => $value) { |
|
168 | + foreach ($this->repeaterPages as $key => $value) |
|
169 | + { |
|
167 | 170 | $jailedObjects[$key] = $value->createJail(); |
168 | 171 | } |
169 | 172 | |
@@ -183,7 +186,8 @@ discard block |
||
183 | 186 | { |
184 | 187 | $namespace = $pageView->getType(); |
185 | 188 | |
186 | - switch ($namespace) { |
|
189 | + switch ($namespace) |
|
190 | + { |
|
187 | 191 | case BasePageView::STATIC_TYPE: |
188 | 192 | $this->handleTrackableStaticPageView($pageView); |
189 | 193 | |
@@ -250,7 +254,8 @@ discard block |
||
250 | 254 | 'site' => $this->configuration->getConfiguration(), |
251 | 255 | ]); |
252 | 256 | |
253 | - if (empty($pageView['title'])) { |
|
257 | + if (empty($pageView['title'])) |
|
258 | + { |
|
254 | 259 | return; |
255 | 260 | } |
256 | 261 | |
@@ -274,33 +279,40 @@ discard block |
||
274 | 279 | $dataSource = null; |
275 | 280 | $namespace = null; |
276 | 281 | |
277 | - if (isset($frontMatter['collection'])) { |
|
282 | + if (isset($frontMatter['collection'])) |
|
283 | + { |
|
278 | 284 | $dataSource = &$this->collectionManager->getCollections(); |
279 | 285 | $namespace = 'collection'; |
280 | - } elseif (isset($frontMatter['dataset'])) { |
|
286 | + } |
|
287 | + elseif (isset($frontMatter['dataset'])) |
|
288 | + { |
|
281 | 289 | $dataSource = &$this->dataManager->getDataItems(); |
282 | 290 | $namespace = 'dataset'; |
283 | 291 | } |
284 | 292 | |
285 | - if ($dataSource === null) { |
|
293 | + if ($dataSource === null) |
|
294 | + { |
|
286 | 295 | throw new LogicException('Invalid Dynamic PageView defined'); |
287 | 296 | } |
288 | 297 | |
289 | 298 | $collection = $frontMatter[$namespace]; |
290 | 299 | |
291 | - if (!isset($dataSource[$collection])) { |
|
300 | + if (!isset($dataSource[$collection])) |
|
301 | + { |
|
292 | 302 | throw new CollectionNotFoundException("The '{$collection}' {$namespace} is not defined"); |
293 | 303 | } |
294 | 304 | |
295 | 305 | /** @var ContentItem|DataItem $item */ |
296 | - foreach ($dataSource[$collection] as &$item) { |
|
306 | + foreach ($dataSource[$collection] as &$item) |
|
307 | + { |
|
297 | 308 | $item->evaluateFrontMatter($frontMatter, [ |
298 | 309 | 'site' => $this->configuration->getConfiguration(), |
299 | 310 | ]); |
300 | 311 | $item->saveParentPageView($pageView); |
301 | 312 | $item->buildPermalink(true); |
302 | 313 | |
303 | - if ($item instanceof ContentItem) { |
|
314 | + if ($item instanceof ContentItem) |
|
315 | + { |
|
304 | 316 | $this->registerExplicitAssets($item); |
305 | 317 | } |
306 | 318 | |
@@ -325,7 +337,8 @@ discard block |
||
325 | 337 | ]); |
326 | 338 | $pageView->configurePermalinks(); |
327 | 339 | |
328 | - if (empty($pageView['title'])) { |
|
340 | + if (empty($pageView['title'])) |
|
341 | + { |
|
329 | 342 | return; |
330 | 343 | } |
331 | 344 | |
@@ -336,21 +349,25 @@ discard block |
||
336 | 349 | { |
337 | 350 | $assets = $contentItem['assets']; |
338 | 351 | |
339 | - if (!is_array($assets) && $assets !== null) { |
|
352 | + if (!is_array($assets) && $assets !== null) |
|
353 | + { |
|
340 | 354 | $this->logger->warning('The "assets" directive in FrontMatter must be null or an array of strings.'); |
341 | 355 | |
342 | 356 | return; |
343 | 357 | } |
344 | 358 | |
345 | - if ($assets === null || count($assets) === 0) { |
|
359 | + if ($assets === null || count($assets) === 0) |
|
360 | + { |
|
346 | 361 | return; |
347 | 362 | } |
348 | 363 | |
349 | 364 | $sourceFolder = fs::path($contentItem->getAbsoluteFilePath())->getParentDirectory(); |
350 | 365 | $permalinkFolder = fs::path($contentItem->getTargetFile())->getParentDirectory(); |
351 | 366 | |
352 | - foreach ($assets as $i => $asset) { |
|
353 | - if (!is_string($asset)) { |
|
367 | + foreach ($assets as $i => $asset) |
|
368 | + { |
|
369 | + if (!is_string($asset)) |
|
370 | + { |
|
354 | 371 | $this->logger->warning('{path}: Item #{index} of the "assets" array is not a string', [ |
355 | 372 | 'path' => $contentItem->getRelativeFilePath(), |
356 | 373 | 'index' => $i, |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function compileManager(): void |
27 | 27 | { |
28 | - if ($this->pageManager === null) { |
|
28 | + if ($this->pageManager === null) |
|
29 | + { |
|
29 | 30 | return; |
30 | 31 | } |
31 | 32 | |
@@ -41,9 +42,11 @@ discard block |
||
41 | 42 | { |
42 | 43 | $jailedMenu = []; |
43 | 44 | |
44 | - foreach ($this->siteMenu as $key => $value) { |
|
45 | + foreach ($this->siteMenu as $key => $value) |
|
46 | + { |
|
45 | 47 | // If it's an array, it means the parent is hidden from the site menu therefore its children should be too |
46 | - if (is_array($this->siteMenu[$key])) { |
|
48 | + if (is_array($this->siteMenu[$key])) |
|
49 | + { |
|
47 | 50 | continue; |
48 | 51 | } |
49 | 52 | |
@@ -58,7 +61,8 @@ discard block |
||
58 | 61 | */ |
59 | 62 | public function buildFromPageViews($pageViews): void |
60 | 63 | { |
61 | - foreach ($pageViews as $pageView) { |
|
64 | + foreach ($pageViews as $pageView) |
|
65 | + { |
|
62 | 66 | $this->addToSiteMenu($pageView); |
63 | 67 | } |
64 | 68 | } |
@@ -70,38 +74,50 @@ discard block |
||
70 | 74 | { |
71 | 75 | $frontMatter = $pageView->getFrontMatter(); |
72 | 76 | |
73 | - if (isset($frontMatter['menu']) && !$frontMatter['menu']) { |
|
77 | + if (isset($frontMatter['menu']) && !$frontMatter['menu']) |
|
78 | + { |
|
74 | 79 | return; |
75 | 80 | } |
76 | 81 | |
77 | 82 | $url = trim((string)$pageView->getPermalink(), '/'); |
78 | 83 | |
79 | 84 | // @TODO in the next breaking release, remove this check and allow the homepage to be indexed as '.' |
80 | - if (empty($url)) { |
|
85 | + if (empty($url)) |
|
86 | + { |
|
81 | 87 | return; |
82 | 88 | } |
83 | 89 | |
84 | 90 | $root = &$this->siteMenu; |
85 | 91 | $dirs = explode('/', $url); |
86 | 92 | |
87 | - while (count($dirs) > 0) { |
|
93 | + while (count($dirs) > 0) |
|
94 | + { |
|
88 | 95 | $name = array_shift($dirs); |
89 | 96 | $name = (!empty($name)) ? $name : '.'; |
90 | 97 | |
91 | - if (!is_null($name) && count($dirs) == 0) { |
|
92 | - if (isset($root[$name]) && is_array($root[$name])) { |
|
98 | + if (!is_null($name) && count($dirs) == 0) |
|
99 | + { |
|
100 | + if (isset($root[$name]) && is_array($root[$name])) |
|
101 | + { |
|
93 | 102 | $children = &$pageView->getChildren(); |
94 | 103 | $children = $root[$name]['children']; |
95 | 104 | } |
96 | 105 | |
97 | 106 | $root[$name] = &$pageView; |
98 | - } else { |
|
99 | - if (!isset($root[$name])) { |
|
107 | + } |
|
108 | + else |
|
109 | + { |
|
110 | + if (!isset($root[$name])) |
|
111 | + { |
|
100 | 112 | $root[$name]['children'] = []; |
101 | 113 | $root = &$root[$name]['children']; |
102 | - } elseif (isset($root[$name]) && is_array($root[$name])) { |
|
114 | + } |
|
115 | + elseif (isset($root[$name]) && is_array($root[$name])) |
|
116 | + { |
|
103 | 117 | $root = &$root[$name]['children']; |
104 | - } else { |
|
118 | + } |
|
119 | + else |
|
120 | + { |
|
105 | 121 | $root = &$root[$name]->getChildren(); |
106 | 122 | } |
107 | 123 | } |
@@ -47,17 +47,20 @@ |
||
47 | 47 | 'include' => [], |
48 | 48 | ]; |
49 | 49 | |
50 | - if (!fs::exists($this->themeFolder)) { |
|
50 | + if (!fs::exists($this->themeFolder)) |
|
51 | + { |
|
51 | 52 | throw new FileNotFoundException("The '{$themeName}' theme folder could not be found.'"); |
52 | 53 | } |
53 | 54 | |
54 | - if (fs::exists($this->themeFile)) { |
|
55 | + if (fs::exists($this->themeFile)) |
|
56 | + { |
|
55 | 57 | $themeData = Yaml::parse(file_get_contents($this->themeFile)); |
56 | 58 | |
57 | 59 | $this->themeData = array_merge_recursive($this->themeData, $themeData); |
58 | 60 | } |
59 | 61 | |
60 | - foreach ($this->themeData['include'] as &$include) { |
|
62 | + foreach ($this->themeData['include'] as &$include) |
|
63 | + { |
|
61 | 64 | $include = fs::appendPath($this->themeFolder, $include); |
62 | 65 | } |
63 | 66 | } |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getExplicitAsset($permalink): ?File |
57 | 57 | { |
58 | - if (isset($this->explicitAssets[$permalink])) { |
|
58 | + if (isset($this->explicitAssets[$permalink])) |
|
59 | + { |
|
59 | 60 | return $this->explicitAssets[$permalink]; |
60 | 61 | } |
61 | 62 | |
@@ -85,7 +86,8 @@ discard block |
||
85 | 86 | { |
86 | 87 | $this->logger->notice('Copying manual assets...'); |
87 | 88 | |
88 | - foreach ($this->explicitAssets as $targetPath => $manualAsset) { |
|
89 | + foreach ($this->explicitAssets as $targetPath => $manualAsset) |
|
90 | + { |
|
89 | 91 | $this->handleTrackableItem($manualAsset, [ |
90 | 92 | 'prefix' => '', |
91 | 93 | 'siteTargetPath' => $targetPath, |
@@ -140,20 +142,25 @@ discard block |
||
140 | 142 | */ |
141 | 143 | protected function handleTrackableItem(File $file, array $options = []): mixed |
142 | 144 | { |
143 | - if (!$file->exists()) { |
|
145 | + if (!$file->exists()) |
|
146 | + { |
|
144 | 147 | return null; |
145 | 148 | } |
146 | 149 | |
147 | 150 | $filePath = $file->getRealPath(); |
148 | 151 | $pathToStrip = fs::appendPath(Service::getWorkingDirectory(), $options['prefix']); |
149 | 152 | |
150 | - if (isset($options['siteTargetPath'])) { |
|
153 | + if (isset($options['siteTargetPath'])) |
|
154 | + { |
|
151 | 155 | $siteTargetPath = $options['siteTargetPath']; |
152 | - } else { |
|
156 | + } |
|
157 | + else |
|
158 | + { |
|
153 | 159 | $siteTargetPath = ltrim(str_replace($pathToStrip, '', $filePath), DIRECTORY_SEPARATOR); |
154 | 160 | } |
155 | 161 | |
156 | - try { |
|
162 | + try |
|
163 | + { |
|
157 | 164 | $this->addFileToTracker($file); |
158 | 165 | $this->saveTrackerOptions($file->getRelativeFilePath(), $options); |
159 | 166 | |
@@ -161,7 +168,9 @@ discard block |
||
161 | 168 | $this->logger->info('Copying file: {file}...', [ |
162 | 169 | 'file' => $file->getRelativeFilePath(), |
163 | 170 | ]); |
164 | - } catch (Exception $e) { |
|
171 | + } |
|
172 | + catch (Exception $e) |
|
173 | + { |
|
165 | 174 | $this->logger->error($e->getMessage()); |
166 | 175 | } |
167 | 176 |