Skip to content

Commit

Permalink
Update entry URIs when collection route is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Nov 20, 2024
1 parent a272414 commit 3957c6b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Entries/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Statamic\Data\ContainsCascadingData;
use Statamic\Data\ExistsAsFile;
use Statamic\Data\HasAugmentedData;
use Statamic\Data\HasDirtyState;
use Statamic\Events\CollectionCreated;
use Statamic\Events\CollectionCreating;
use Statamic\Events\CollectionDeleted;
Expand All @@ -34,7 +35,7 @@

class Collection implements Arrayable, ArrayAccess, AugmentableContract, Contract
{
use ContainsCascadingData, ExistsAsFile, FluentlyGetsAndSets, HasAugmentedData;
use ContainsCascadingData, ExistsAsFile, FluentlyGetsAndSets, HasAugmentedData, HasDirtyState;

protected $handle;
protected $routes = [];
Expand Down Expand Up @@ -484,6 +485,10 @@ public function save()
}
}

if ($this->isDirty('route')) {
Facades\Entry::updateUris($this);
}

Facades\Collection::save($this);

Blink::forget('collection-handles');
Expand All @@ -498,6 +503,8 @@ public function save()
CollectionSaved::dispatch($this);
}

$this->syncOriginal();

return $this;
}

Expand Down Expand Up @@ -928,4 +935,9 @@ public function augmentedArrayData()
'handle' => $this->handle(),
];
}

public function getCurrentDirtyStateAttributes(): array
{
return $this->fileData();
}
}

0 comments on commit 3957c6b

Please sign in to comment.