Skip to content

Commit

Permalink
Allow the use of aliases with the viewPath property. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 30, 2020
1 parent aa9a993 commit 8154416
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -29,8 +29,8 @@
},
"require-dev": {
"nyholm/psr7": "^1.3",
"phpunit/phpunit": "^9.4",
"roave/infection-static-analysis-plugin": "^1.5",
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.6",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.3",
"yiisoft/di": "3.0.x-dev",
Expand Down
2 changes: 1 addition & 1 deletion src/ViewRenderer.php
Expand Up @@ -57,7 +57,7 @@ public function __construct(
public function getViewPath(): string
{
if ($this->viewPath !== null) {
return $this->viewPath;
return $this->aliases->get($this->viewPath);
}

return $this->aliases->get($this->viewBasePath) . ($this->name ? '/' . $this->name : '');
Expand Down
7 changes: 7 additions & 0 deletions tests/ViewRendererTest.php
Expand Up @@ -112,6 +112,13 @@ public function testWithViewPath(): void
$this->assertSame('/dir/', $renderer->getViewPath());
}

public function testWithViewPathWithAlias(): void
{
$renderer = $this->getRenderer()->withViewPath('@views/dir');

$this->assertSame($this->getViewsDir() . '/dir', $renderer->getViewPath());
}

public function testImmutability(): void
{
$original = $this->getRenderer();
Expand Down

0 comments on commit 8154416

Please sign in to comment.