Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ConstructsPageSchemas schemas trait #632

Merged
merged 4 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

18 changes: 18 additions & 0 deletions packages/framework/src/Framework/Factories/Concerns/HasFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Hyde\Framework\Factories\Concerns;

use Hyde\Framework\Factories\BlogPostDataFactory;
use Hyde\Framework\Factories\HydePageDataFactory;
use Hyde\Pages\MarkdownPost;

trait HasFactory
{
public function constructFactoryData(PageDataFactory $data): void
Expand All @@ -12,4 +16,18 @@ public function constructFactoryData(PageDataFactory $data): void
$this->{$key} = $value;
}
}

protected function constructPageSchemas(): void
{
$this->constructPageSchema();

if ($this instanceof MarkdownPost) {
$this->constructFactoryData(new BlogPostDataFactory($this->matter, $this->markdown));
}
}

protected function constructPageSchema(): void
{
$this->constructFactoryData(new HydePageDataFactory($this->matter, $this->markdown ?? false, $this::class, $this->identifier, $this->getOutputPath(), $this->routeKey));
}
}
2 changes: 0 additions & 2 deletions packages/framework/src/Pages/Concerns/HydePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Hyde\Foundation\PageCollection;
use Hyde\Framework\Actions\SourceFileParser;
use Hyde\Framework\Concerns\InteractsWithFrontMatter;
use Hyde\Framework\Concerns\Internal\ConstructsPageSchemas;
use Hyde\Framework\Factories\Concerns\HasFactory;
use Hyde\Framework\Features\Metadata\PageMetadataBag;
use Hyde\Framework\Features\Navigation\NavigationData;
Expand Down Expand Up @@ -37,7 +36,6 @@
*/
abstract class HydePage implements PageSchema
{
use ConstructsPageSchemas;
use InteractsWithFrontMatter;
use HasFactory;

Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/HydePageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @covers \Hyde\Pages\Concerns\HydePage
* @covers \Hyde\Pages\Concerns\BaseMarkdownPage
* @covers \Hyde\Framework\Concerns\Internal\ConstructsPageSchemas
* @covers \Hyde\Framework\Factories\Concerns\HasFactory
* @covers \Hyde\Framework\Factories\NavigationDataFactory
* @covers \Hyde\Framework\Factories\FeaturedImageFactory
* @covers \Hyde\Framework\Factories\HydePageDataFactory
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/MarkdownPostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* @covers \Hyde\Pages\MarkdownPost
* @covers \Hyde\Framework\Concerns\Internal\ConstructsPageSchemas
* @covers \Hyde\Framework\Factories\Concerns\HasFactory
*/
class MarkdownPostTest extends TestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Test the constructor actions and schema constructors for page models.
*
* @covers \Hyde\Framework\Concerns\Internal\ConstructsPageSchemas
* @covers \Hyde\Framework\Factories\Concerns\HasFactory
* @covers \Hyde\Framework\Factories\NavigationDataFactory
* @covers \Hyde\Framework\Factories\FeaturedImageFactory
* @covers \Hyde\Framework\Factories\HydePageDataFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
* @covers \Hyde\Framework\Features\Navigation\DocumentationSidebar
* @covers \Hyde\Framework\Concerns\Internal\ConstructsPageSchemas
* @covers \Hyde\Framework\Factories\Concerns\HasFactory
* @covers \Hyde\Framework\Factories\NavigationDataFactory
*/
class DocumentationSidebarTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Unit/DocumentationPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* @covers \Hyde\Pages\DocumentationPage
* @covers \Hyde\Framework\Concerns\Internal\ConstructsPageSchemas
* @covers \Hyde\Framework\Factories\Concerns\HasFactory
* @covers \Hyde\Framework\Factories\NavigationDataFactory
*/
class DocumentationPageTest extends TestCase
Expand Down