Skip to content

Commit

Permalink
LatteRenderer: extract getTaskGroups()
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Sep 19, 2022
1 parent e2f11c2 commit f10aaa0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Renderer/Latte/LatteRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,20 @@ public function render(ProgressBar $progressBar, Index $index): void
FileSystem::createDir($this->outputDir);

$config = new ConfigParameters($this->title, $this->version);
$tasks = $this->getTaskGroups($index);
$progressBar->setMaxSteps(array_sum(array_map('count', array_column($tasks, 1))));
$this->forkLoop($progressBar, $this->createTaskIterator($index, $config, $tasks));
}


/**
* @return array<array{callable(Index, ConfigParameters, mixed): string, array}>
*/
protected function getTaskGroups(Index $index): array
{
$assets = iterator_to_array(Finder::findFiles()->from(__DIR__ . '/Template/assets'));

$tasks = [
return [
[$this->copyAsset(...), $assets],
[$this->renderElementsJs(...), [null]],
[$this->renderIndex(...), [null]],
Expand All @@ -78,9 +89,6 @@ public function render(ProgressBar $progressBar, Index $index): void
[$this->renderFunction(...), array_filter($index->function, $this->filter->filterFunctionPage(...))],
[$this->renderSource(...), array_keys(array_filter($index->files, $this->filter->filterSourcePage(...)))],
];

$progressBar->setMaxSteps(array_sum(array_map('count', array_column($tasks, 1))));
$this->forkLoop($progressBar, $this->createTaskIterator($index, $config, $tasks));
}


Expand Down

0 comments on commit f10aaa0

Please sign in to comment.