diff --git a/src/Modules/ContentTypes/ContentType.php b/src/Modules/ContentTypes/ContentType.php index b756b20..8565e22 100644 --- a/src/Modules/ContentTypes/ContentType.php +++ b/src/Modules/ContentTypes/ContentType.php @@ -6,6 +6,12 @@ use Tapestry\Entities\Taxonomy; use Tapestry\Modules\Source\SourceInterface; +/** + * Class ContentType + * + * @todo #322 write unit test... + * @package Tapestry\Modules\ContentTypes + */ class ContentType { /** @@ -235,6 +241,7 @@ public function getSourceList(string $order = 'desc') } /** + * @todo should this not be done when a Source is bucketed into this content type? * @param Project $project * @throws \Exception */ diff --git a/src/Modules/Generators/TaxonomyArchiveGenerator.php b/src/Modules/Generators/TaxonomyArchiveGenerator.php index 72a205a..e67384f 100644 --- a/src/Modules/Generators/TaxonomyArchiveGenerator.php +++ b/src/Modules/Generators/TaxonomyArchiveGenerator.php @@ -2,6 +2,7 @@ namespace Tapestry\Modules\Generators; +use Tapestry\Entities\DependencyGraph\SimpleNode; use Tapestry\Entities\Project; use Tapestry\Modules\Source\ClonedSource; use Tapestry\Modules\Source\SourceInterface; @@ -59,8 +60,11 @@ public function generate(Project $project): array return [$this->source]; } - foreach ($uses as $use){ + // Add the Generator to the graph + $nodeId = $this->source->getUid().'_generator_TaxonomyGenerator_'.time(); + $project->addSource($this->source->getUid(), new SimpleNode($nodeId, 'TaxonomyGenerator')); + foreach ($uses as $use){ if (! $data = $this->source->getData($use.'_items')) { continue; } @@ -69,6 +73,8 @@ public function generate(Project $project): array foreach ($data as $taxonomyName => $files) { $newFile = new ClonedSource($this->source); + $newFile->setUid($newFile->getUid().'_taxonomyarchive_'.$taxonomyName); + $newFile->setOverloaded('filename', $taxonomyName); // @todo refactor so that a TaxonomyViewHelper is injected? $newFile->setData([ @@ -79,8 +85,13 @@ public function generate(Project $project): array $use.'_items' => $files, $use => $classifications, ]); - $newFile->setUid($newFile->getUid().'_'.$taxonomyName); - $newFile->setOverloaded('filename', $taxonomyName); + + + // Add Generated Source to Source Graph + $project->addSource($nodeId, $newFile); + + // @todo before we can complete this section of 315 the ContentType needs unit testing to ensure it works as expected. + array_push($generated, $newFile); } } diff --git a/tests/Unit/ContentGeneratorsNTest.php b/tests/Unit/ContentGeneratorsNTest.php index 5bcda3e..d60ac51 100644 --- a/tests/Unit/ContentGeneratorsNTest.php +++ b/tests/Unit/ContentGeneratorsNTest.php @@ -264,6 +264,17 @@ public function testTaxonomyArchiveGenerator() $this->assertTrue(is_array($result)); $this->assertCount(2, $result); + + $graph = new Debug($project->getGraph()); + $n = $graph->graphViz('configuration'); + + // + // Check Graph is updated with correct dependencies + // + $dep = (new Resolver())->resolve($project->getSource('configuration')); + $this->assertCount(10, $dep); // (8 initial sources + 2 for each generated) + + $n = 1; } // @todo add test to check this modifies the graph