|
11 | 11 | use Statamic\Events\TermDeleted; |
12 | 12 | use Statamic\Events\AssetSaved; |
13 | 13 | use Statamic\Events\AssetDeleted; |
| 14 | +use Statamic\Events\CollectionTreeSaved; |
| 15 | +use Statamic\Events\NavTreeSaved; |
14 | 16 | use Statamic\Facades\URL; |
15 | 17 | use Illuminate\Support\Facades\Log; // Already present, but good to confirm |
16 | 18 |
|
@@ -109,6 +111,8 @@ protected function shouldHandleEvent(Event $event): bool |
109 | 111 | 'Statamic\Events\TermDeleted' => 'term_deleted', |
110 | 112 | 'Statamic\Events\AssetSaved' => 'asset_saved', |
111 | 113 | 'Statamic\Events\AssetDeleted' => 'asset_deleted', |
| 114 | + 'Statamic\Events\CollectionTreeSaved' => 'collection_tree_saved', |
| 115 | + 'Statamic\Events\NavTreeSaved' => 'nav_tree_saved', |
112 | 116 | ]; |
113 | 117 |
|
114 | 118 | $configKey = $eventMap[$eventClass] ?? null; |
@@ -153,6 +157,22 @@ protected function getUrlsToPurge(Event $event): array |
153 | 157 | } |
154 | 158 | } |
155 | 159 |
|
| 160 | + if ($event instanceof CollectionTreeSaved) { |
| 161 | + $tree = $event->tree; |
| 162 | + if ($tree && $tree->collection()) { |
| 163 | + $collection = $tree->collection(); |
| 164 | + if ($collection->url()) { |
| 165 | + $urls[] = URL::makeAbsolute($collection->url()); |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | + |
| 170 | + if ($event instanceof NavTreeSaved) { |
| 171 | + // Navigation tree saved - this happens when nav items are reordered |
| 172 | + // Since navigation appears on multiple pages, we purge everything by default |
| 173 | + // If purge_everything_fallback is disabled, this will do nothing (intended behavior) |
| 174 | + } |
| 175 | + |
156 | 176 | $urls = array_filter($urls); |
157 | 177 |
|
158 | 178 | return array_unique($urls); |
|
0 commit comments