Ensure symlink is always created

This commit is contained in:
Nicolas Le Goff
2014-05-27 19:30:29 +02:00
parent 2c6ba6b99f
commit 09785c67bd
4 changed files with 16 additions and 0 deletions

View File

@@ -24,4 +24,11 @@ abstract class AbstractStaticMode extends AbstractServerMode
parent::__construct($mapping);
}
protected function ensureSymlink($pathFile)
{
if (false === $this->symlinker->hasSymlink($pathFile)) {
$this->symlinker->symlink($pathFile);
}
}
}

View File

@@ -40,6 +40,8 @@ class Apache extends AbstractStaticMode implements StaticFileModeInterface
*/
public function getUrl($pathFile)
{
$this->ensureSymlink($pathFile);
return Url::factory(sprintf('%s/%s', $this->mapping['mount-point'], $this->symlinker->getSymlinkBasePath($pathFile)));
}

View File

@@ -40,6 +40,8 @@ class Nginx extends AbstractStaticMode implements StaticFileModeInterface
*/
public function getUrl($pathFile)
{
$this->ensureSymlink($pathFile);
return Url::factory(sprintf('%s/%s', $this->mapping['mount-point'], $this->symlinker->getSymlinkBasePath($pathFile)));
}

View File

@@ -86,4 +86,9 @@ class SymLinker
$this->getSymlinkBasePath($pathFile)
);
}
public function hasSymlink($pathFile)
{
return file_exists($this->getSymlinkPath($pathFile));
}
}