Skip to content

Commit

Permalink
Merge pull request #97 from weaverryan/expose-more-from-builder
Browse files Browse the repository at this point in the history
Exposing Metas and ParseQueue from Builder
  • Loading branch information
jwage authored Mar 8, 2019
2 parents 8adee80 + 859e2d5 commit 9ee95e5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -41,6 +42,9 @@ class Builder
/** @var Documents */
private $documents;

/** @var ParseQueue|null */
private $parseQueue;

/** @var Copier */
private $copier;

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions lib/Event/PreBuildParseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 9ee95e5

Please sign in to comment.