|
9 | 9 | use Illuminate\Support\Facades\Gate; |
10 | 10 | use Illuminate\Support\Facades\Log; |
11 | 11 | use Illuminate\Support\Facades\Route; |
| 12 | +use Illuminate\Support\LazyCollection; |
12 | 13 | use Illuminate\Support\Str; |
13 | 14 | use Spatie\ErrorSolutions\Contracts\SolutionProviderRepository; |
14 | 15 | use Statamic\API\Middleware\Cache; |
|
20 | 21 | use Statamic\Facades\Permission; |
21 | 22 | use Statamic\Facades\Search; |
22 | 23 | use Statamic\Http\Middleware\RequireStatamicPro; |
| 24 | +use Statamic\Listeners\UpdateAssetReferences; |
| 25 | +use Statamic\Listeners\UpdateTermReferences; |
23 | 26 | use Statamic\Providers\AddonServiceProvider; |
24 | 27 | use Statamic\Statamic; |
25 | 28 | use StatamicRadPack\Runway\GraphQL\NestedFieldsType; |
@@ -69,6 +72,7 @@ public function boot() |
69 | 72 | ->registerNavigation() |
70 | 73 | ->registerBlueprints() |
71 | 74 | ->registerSearchProvider() |
| 75 | + ->registerReferenceUpdaterHook() |
72 | 76 | ->bootGraphQl() |
73 | 77 | ->bootApi() |
74 | 78 | ->bootModelEventListeners() |
@@ -245,6 +249,20 @@ protected function registerSearchProvider(): self |
245 | 249 | return $this; |
246 | 250 | } |
247 | 251 |
|
| 252 | + protected function registerReferenceUpdaterHook(): self |
| 253 | + { |
| 254 | + $referenceUpdaterHook = function ($payload, $next) { |
| 255 | + return LazyCollection::make(Runway::allResources())->flatMap(function (Resource $resource) { |
| 256 | + return $resource->newEloquentQuery()->lazy(); |
| 257 | + }); |
| 258 | + }; |
| 259 | + |
| 260 | + UpdateTermReferences::hook('additional', $referenceUpdaterHook); |
| 261 | + UpdateAssetReferences::hook('additional', $referenceUpdaterHook); |
| 262 | + |
| 263 | + return $this; |
| 264 | + } |
| 265 | + |
248 | 266 | protected function bootModelEventListeners(): self |
249 | 267 | { |
250 | 268 | Runway::allResources() |
|
0 commit comments