Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing Metas and ParseQueue from Builder #97

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}