Skip to content

Commit

Permalink
Merge pull request #144 from hydephp/remove-deprecated-code
Browse files Browse the repository at this point in the history
Remove deprecated code
  • Loading branch information
caendesilva authored Jul 3, 2022
2 parents 938ca3e + e30aecb commit 3739250
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ This serves two purposes:

### Removed
- Removes the automatic check to see if the configuration file is up to date https://github.com/hydephp/develop/pull/143
- Remove deprecated `Hyde::titleFromSlug()` helper, use `Hyde::makeTitle()` instead
- Removed deprecated CollectionService::getBladePageList, is renamed to getBladePageFiles
- Removed deprecated CollectionService::getMarkdownPageList, is renamed to getMarkdownPageFiles
- Removed deprecated CollectionService::getMarkdownPostList, is renamed to getMarkdownPostFiles
- Removed deprecated CollectionService::getDocumentationPageList, is renamed to getDocumentationPageFiles

### Fixed
- Fix bug causing files starting with underscores to add empty values to the file collection array https://github.com/hydephp/develop/pull/140
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function generatePageObject(string $slug): object
public function getSourceFileSlugs(): array
{
return array_diff(
CollectionService::getDocumentationPageList(),
CollectionService::getDocumentationPageFiles(),
config('docs.exclude_from_search', [])
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Actions/GeneratesNavigationMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ protected function getListOfCustomPages(): array
{
return array_unique(
array_merge(
CollectionService::getBladePageList(),
CollectionService::getMarkdownPageList()
CollectionService::getBladePageFiles(),
CollectionService::getMarkdownPageFiles()
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/src/Commands/HydeBuildSearchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function createSearchPage(): void

protected function guesstimateGenerationTime(): float
{
return count(CollectionService::getDocumentationPageList()) * 52.5;
return count(CollectionService::getDocumentationPageFiles()) * 52.5;
}

protected function getExecutionTimeInMs(float $timeStart): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ protected function canGenerateSitemap(): bool
protected function canGenerateFeed(): bool
{
return RssFeedService::canGenerateFeed()
&& count(CollectionService::getMarkdownPostList()) > 0;
&& count(CollectionService::getMarkdownPostFiles()) > 0;
}

protected function canGenerateSearch(): bool
{
return Features::hasDocumentationSearch()
&& count(CollectionService::getDocumentationPageList()) > 0;
&& count(CollectionService::getDocumentationPageFiles()) > 0;
}
}
3 changes: 0 additions & 3 deletions packages/framework/src/Helpers/HydeHelperFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public static function hasFeature(string $feature): bool
return Features::enabled($feature);
}

/**
* @since 0.44.0-beta (renamed from titleFromSlug)
*/
public static function makeTitle(string $slug): string
{
$alwaysLowercase = ['a', 'an', 'the', 'in', 'on', 'by', 'with', 'of', 'and', 'or', 'but'];
Expand Down
9 changes: 0 additions & 9 deletions packages/framework/src/Hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Hyde\Framework\Concerns\Internal\FileHelpers;
use Hyde\Framework\Concerns\Internal\FluentPathHelpers;
use Hyde\Framework\Helpers\HydeHelperFacade;
use Illuminate\Support\Str;

/**
* General facade for Hyde services.
Expand Down Expand Up @@ -43,12 +42,4 @@ public static function setBasePath(string $path): void
{
static::$basePath = $path;
}

/**
* @deprecated v0.44.0-beta use Hyde::makeTitle() instead.
*/
public static function titleFromSlug(string $slug): string
{
return Str::title(str_replace('-', ' ', ($slug)));
}
}
40 changes: 0 additions & 40 deletions packages/framework/src/Services/CollectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,43 +40,9 @@ public static function getSourceFileListForModel(string $model): array|false
return $files;
}

/**
* @deprecated v0.44.x Is renamed to getBladePageFiles
*/
public static function getBladePageList(): array
{
return static::getBladePageFiles();
}

/**
* @deprecated v0.44.x Is renamed to getMarkdownPageFiles
*/
public static function getMarkdownPageList(): array
{
return static::getMarkdownPageFiles();
}

/**
* @deprecated v0.44.x Is renamed to getMarkdownPostFiles
*/
public static function getMarkdownPostList(): array
{
return static::getMarkdownPostFiles();
}

/**
* @deprecated v0.44.x Is renamed to getDocumentationPageFiles
*/
public static function getDocumentationPageList(): array
{
return static::getDocumentationPageFiles();
}

/**
* Get all the Blade files in the resources/views/vendor/hyde/pages directory.
*
* @since 0.44.x replaces getBladePageList
*
* @return array
*/
public static function getBladePageFiles(): array
Expand All @@ -87,8 +53,6 @@ public static function getBladePageFiles(): array
/**
* Get all the Markdown files in the _pages directory.
*
* @since 0.44.x replaces getMarkdownPageList
*
* @return array
*/
public static function getMarkdownPageFiles(): array
Expand All @@ -99,8 +63,6 @@ public static function getMarkdownPageFiles(): array
/**
* Get all the Markdown files in the _posts directory.
*
* @since 0.44.x replaces getMarkdownPostList
*
* @return array
*/
public static function getMarkdownPostFiles(): array
Expand All @@ -111,8 +73,6 @@ public static function getMarkdownPostFiles(): array
/**
* Get all the Markdown files in the _docs directory.
*
* @since 0.44.x replaces getDocumentationPageList
*
* @return array
*/
public static function getDocumentationPageFiles(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function withoutHidden(): self
*/
protected function getSidebarItems(): array
{
return CollectionService::getDocumentationPageList();
return CollectionService::getDocumentationPageFiles();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/framework/src/Services/ValidationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function check_documentation_site_has_an_index_page(Result $result): Resu
return $result->skip('The documentation page feature is disabled in config');
}

if (count(CollectionService::getDocumentationPageList()) === 0) {
if (count(CollectionService::getDocumentationPageFiles()) === 0) {
return $result->skip('There are no documentation pages');
}

Expand Down Expand Up @@ -121,8 +121,8 @@ public function check_a_torchlight_api_token_is_set(Result $result): Result
public function check_for_conflicts_between_blade_and_markdown_pages(Result $result): Result
{
$conflicts = array_intersect(
CollectionService::getMarkdownPageList(),
CollectionService::getBladePageList()
CollectionService::getMarkdownPageFiles(),
CollectionService::getBladePageFiles()
);

if (count($conflicts)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function test_can_get_collection_of_slugs()

file_put_contents(Hyde::path('_docs/phpunit-test.md'), "# PHPUnit Test File \n Hello World!");

$array = CollectionService::getDocumentationPageList();
$array = CollectionService::getDocumentationPageFiles();

$this->assertIsArray($array);
$this->assertCount(1, $array);
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/MarkdownPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function tearDown(): void
*/
public function test_can_get_collection_of_slugs()
{
$array = CollectionService::getMarkdownPageList();
$array = CollectionService::getMarkdownPageFiles();

$this->assertIsArray($array);
$this->assertCount(1, $array);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ public function test_class_exists()

public function test_get_source_file_list_for_blade_page()
{
$this->assertEquals(['404', 'index'], CollectionService::getBladePageList());
$this->assertEquals(['404', 'index'], CollectionService::getBladePageFiles());
}

public function test_get_source_file_list_for_markdown_page()
{
touch(Hyde::path('_pages/foo.md'));
$this->assertEquals(['foo'], CollectionService::getMarkdownPageList());
$this->assertEquals(['foo'], CollectionService::getMarkdownPageFiles());
unlink(Hyde::path('_pages/foo.md'));
}

public function test_get_source_file_list_for_markdown_post()
{
touch(Hyde::path('_posts/foo.md'));
$this->assertEquals(['foo'], CollectionService::getMarkdownPostList());
$this->assertEquals(['foo'], CollectionService::getMarkdownPostFiles());
unlink(Hyde::path('_posts/foo.md'));
}

public function test_get_source_file_list_for_documentation_page()
{
touch(Hyde::path('_docs/foo.md'));
$this->assertEquals(['foo'], CollectionService::getDocumentationPageList());
$this->assertEquals(['foo'], CollectionService::getDocumentationPageFiles());
unlink(Hyde::path('_docs/foo.md'));
}

Expand Down Expand Up @@ -135,28 +135,28 @@ public function test_blade_page_files_starting_with_underscore_are_ignored()
$this->assertEquals([
'404',
'index',
], CollectionService::getBladePageList());
], CollectionService::getBladePageFiles());
unlink(Hyde::path('_pages/_foo.blade.php'));
}

public function test_markdown_page_files_starting_with_underscore_are_ignored()
{
touch(Hyde::path('_pages/_foo.md'));
$this->assertEquals([], CollectionService::getMarkdownPageList());
$this->assertEquals([], CollectionService::getMarkdownPageFiles());
unlink(Hyde::path('_pages/_foo.md'));
}

public function test_post_files_starting_with_underscore_are_ignored()
{
touch(Hyde::path('_posts/_foo.md'));
$this->assertEquals([], CollectionService::getMarkdownPostList());
$this->assertEquals([], CollectionService::getMarkdownPostFiles());
unlink(Hyde::path('_posts/_foo.md'));
}

public function test_documentation_page_files_starting_with_underscore_are_ignored()
{
touch(Hyde::path('_docs/_foo.md'));
$this->assertEquals([], CollectionService::getDocumentationPageList());
$this->assertEquals([], CollectionService::getDocumentationPageFiles());
unlink(Hyde::path('_docs/_foo.md'));
}

Expand Down

0 comments on commit 3739250

Please sign in to comment.