diff --git a/src/Content/Version.php b/src/Content/Version.php index cba7a1adec..a51ef20320 100644 --- a/src/Content/Version.php +++ b/src/Content/Version.php @@ -39,6 +39,18 @@ public function content(string $language = 'default'): Content ); } + /** + * Provides simplified access to the absolute content file path. + * This should stay an internal method and be removed as soon as + * the dependency on file storage methods is resolved more clearly. + * + * @internal + */ + public function contentFile(string $language = 'default'): string + { + return $this->model->storage()->contentFile($this->id, $this->language($language)); + } + /** * Creates a new version for the given language * diff --git a/tests/Content/VersionTest.php b/tests/Content/VersionTest.php index a26fcbeacd..4a2f629a1a 100644 --- a/tests/Content/VersionTest.php +++ b/tests/Content/VersionTest.php @@ -122,6 +122,37 @@ public function testContentSingleLanguage(): void $this->assertSame('Test', $version->content()->get('title')->value()); } + /** + * @covers ::contentFile + */ + public function testContentFileMultiLanguage(): void + { + $this->setUpMultiLanguage(); + + $version = new Version( + model: $this->model, + id: VersionId::published() + ); + + $this->assertSame($this->model->root() . '/article.en.txt', $version->contentFile()); + $this->assertSame($this->model->root() . '/article.de.txt', $version->contentFile('de')); + } + + /** + * @covers ::contentFile + */ + public function testContentFileSingleLanguage(): void + { + $this->setUpSingleLanguage(); + + $version = new Version( + model: $this->model, + id: VersionId::published() + ); + + $this->assertSame($this->model->root() . '/article.txt', $version->contentFile()); + } + /** * @covers ::create */