diff --git a/lib/Builder.php b/lib/Builder.php index e53379ed..c6ded6e6 100644 --- a/lib/Builder.php +++ b/lib/Builder.php @@ -15,6 +15,7 @@ use Doctrine\RST\Event\PreBuildScanEvent; use Doctrine\RST\Meta\CachedMetasLoader; use Doctrine\RST\Meta\Metas; +use LogicException; use Symfony\Component\Filesystem\Filesystem; use function is_dir; @@ -41,6 +42,9 @@ class Builder /** @var Documents */ private $documents; + /** @var ParseQueue|null */ + private $parseQueue; + /** @var Copier */ private $copier; @@ -108,6 +112,20 @@ public function getIndexName() : string return $this->indexName; } + public function getMetas() : Metas + { + return $this->metas; + } + + public function getParseQueue() : ParseQueue + { + if ($this->parseQueue === null) { + throw new LogicException('The ParseQueue is not set until after the build is complete'); + } + + return $this->parseQueue; + } + public function build( string $directory, string $targetDirectory = 'output' @@ -164,7 +182,7 @@ private function parse(string $directory, string $targetDirectory, ParseQueue $p { $this->configuration->dispatchEvent( PreBuildParseEvent::PRE_BUILD_PARSE, - new PreBuildParseEvent($this, $directory, $targetDirectory) + new PreBuildParseEvent($this, $directory, $targetDirectory, $parseQueue) ); $parseQueueProcessor = new ParseQueueProcessor( diff --git a/lib/Event/PreBuildParseEvent.php b/lib/Event/PreBuildParseEvent.php index 488bc096..e251cf61 100644 --- a/lib/Event/PreBuildParseEvent.php +++ b/lib/Event/PreBuildParseEvent.php @@ -4,7 +4,23 @@ namespace Doctrine\RST\Event; +use Doctrine\RST\Builder; + final class PreBuildParseEvent extends BuildEvent { public const PRE_BUILD_PARSE = 'preBuildParse'; + + /** @var Builder\ParseQueue */ + private $parseQueue; + + public function __construct(Builder $builder, string $directory, string $targetDirectory, Builder\ParseQueue $parseQueue) + { + parent::__construct($builder, $directory, $targetDirectory); + $this->parseQueue = $parseQueue; + } + + public function getParseQueue() : Builder\ParseQueue + { + return $this->parseQueue; + } }