Skip to content

Commit

Permalink
Remove deprecated CollectionService::findModelFromFilePath()
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 31, 2022
1 parent 8b45e93 commit 5697712
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 106 deletions.
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ This serves two purposes:
- for soon-to-be removed features.

### Removed
- Remove deprecated Hyde::uriPath() helper
- Removed deprecated Hyde::uriPath() helper
- Removed deprecated CollectionService::findModelFromFilePath()

### Fixed
- for any bug fixes.
Expand Down
33 changes: 0 additions & 33 deletions packages/framework/src/Services/DiscoveryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,6 @@ public static function getFilePathForModelClassFiles(string $model): string
return $model::getSourceDirectory();
}

/**
* Determine the Page Model to use for a given file path.
*
* @deprecated v0.47.0-beta - Use the Router instead.
*
* @param string $filepath
* @return string|false The model class constant, or false if none was found.
*
* @see \Hyde\Framework\Testing\Unit\DiscoveryServiceCanFindModelFromCustomSourceFilePathTest
*/
public static function findModelFromFilePath(string $filepath): string|false
{
if (str_starts_with($filepath, MarkdownPost::getSourceDirectory())) {
return MarkdownPost::class;
}

if (str_starts_with($filepath, DocumentationPage::getSourceDirectory())) {
return DocumentationPage::class;
}

if (str_starts_with($filepath, MarkdownPage::getSourceDirectory())
&& str_ends_with($filepath, '.md')) {
return MarkdownPage::class;
}

if (str_starts_with($filepath, BladePage::getSourceDirectory())
&& str_ends_with($filepath, '.blade.php')) {
return BladePage::class;
}

return false;
}

/**
* Create a filepath that can be opened in the browser from a terminal.
*
Expand Down
10 changes: 0 additions & 10 deletions packages/framework/tests/Feature/DiscoveryServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public function deleteContentSourceTestFiles()
unlink(Hyde::path(DiscoveryService::getFilePathForModelClassFiles(BladePage::class).'/test.blade.php'));
}

public function test_find_model_from_file_path()
{
$this->assertEquals(MarkdownPage::class, DiscoveryService::findModelFromFilePath('_pages/test.md'));
$this->assertEquals(MarkdownPost::class, DiscoveryService::findModelFromFilePath('_posts/test.md'));
$this->assertEquals(DocumentationPage::class, DiscoveryService::findModelFromFilePath('_docs/test.md'));
$this->assertEquals(BladePage::class, DiscoveryService::findModelFromFilePath('_pages/test.blade.php'));

$this->assertFalse(DiscoveryService::findModelFromFilePath('_foo/test.txt'));
}

public function test_get_parser_class_for_model()
{
$this->assertEquals(MarkdownPageParser::class, DiscoveryService::getParserClassForModel(MarkdownPage::class));
Expand Down

This file was deleted.

0 comments on commit 5697712

Please sign in to comment.