Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Dec 2, 2024
1 parent 0d2403d commit 032322a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/Entries/EntryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function findOrFail($id);

public function findByUri(string $uri);

public function make();
public function make(string $collection);

public function query();

Expand Down
8 changes: 8 additions & 0 deletions src/Entries/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Collection implements Arrayable, ArrayAccess, AugmentableContract, Contrac
protected $autosave;
protected $withEvents = true;

protected $class;

public function __construct()
{
$this->cascade = collect();
Expand Down Expand Up @@ -115,6 +117,11 @@ public function requiresSlugs($require = null)
return $this->fluentlyGetOrSet('requiresSlugs')->args(func_get_args());
}

public function class($class = null)
{
return $this->fluentlyGetOrSet('class')->args(func_get_args());
}

public function titleFormats($formats = null)
{
return $this
Expand Down Expand Up @@ -569,6 +576,7 @@ public function fileData()
'revisions' => $this->revisions,
'title_format' => $this->titleFormats,
'autosave' => $this->autosave,
'class' => $this->class,
];

$array = Arr::except($formerlyToArray, [
Expand Down
8 changes: 7 additions & 1 deletion src/Stache/Repositories/EntryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,14 @@ public function query()
return app(QueryBuilder::class);
}

public function make(): Entry
public function make(string $collectionHandle): Entry
{
$collection = Collection::findByHandle($collectionHandle);

if ($customClass = $collection->class()) {
return app($customClass)->collection($collectionHandle);
}

return app(Entry::class);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Stache/Stores/CollectionsStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public function makeItemFromFile($path, $contents)
->taxonomies(Arr::get($data, 'taxonomies'))
->propagate(Arr::get($data, 'propagate'))
->previewTargets($this->normalizePreviewTargets(Arr::get($data, 'preview_targets', [])))
->autosaveInterval(Arr::get($data, 'autosave'));
->autosaveInterval(Arr::get($data, 'autosave'))
->class(Arr::get($data, 'class'));

if ($dateBehavior = Arr::get($data, 'date_behavior')) {
$collection
Expand Down

0 comments on commit 032322a

Please sign in to comment.