Skip to content

Commit

Permalink
- Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Machy8 committed Oct 14, 2017
1 parent aee6a4c commit 411bf16
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Webloader/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Compiler
/**
* @var string
*/
private $documentRoot = '/';
private $documentRoot;

/**
* @var FilesCollectionRender
Expand Down Expand Up @@ -327,7 +327,11 @@ public function getFilesCollectionRender(): FilesCollectionRender
{
if ( ! $this->filesCollectionRender) {
$this->compile();
$basePath = str_replace($this->documentRoot, '', $this->outputDir);
$basePath = $this->outputDir;

if ($this->documentRoot) {
$basePath = str_replace($this->documentRoot, '', $this->outputDir);
}

$this->filesCollectionRender = new FilesCollectionRender(
$this->filesCollections,
Expand Down Expand Up @@ -416,6 +420,12 @@ public function isCacheEnabled(): bool

public function setDocumentRoot(string $path): Compiler
{
$path = rtrim($path, '/');

if ( ! is_dir($path)) {
throw new Exception('Given document root "' . $path . '" doesn\'t exists or is not a directory.');
}

$this->documentRoot = $path;
return $this;
}
Expand Down

0 comments on commit 411bf16

Please sign in to comment.