Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rapidez/statamic into hybrid-runway
Browse files Browse the repository at this point in the history
  • Loading branch information
BobWez98 committed Jan 22, 2025
2 parents 490c459 + 0c3e3aa commit 7e15cf4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions resources/js/package.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'Vendor/rapidez/core/resources/js/vue'

Vue.component('form-conditions', () => import('./components/FormConditions.vue'));

document.addEventListener('statamic:nocache.replaced', (e) => {
window.app.csrfToken = e?.detail?.csrf ?? window.app.csrfToken
})
7 changes: 7 additions & 0 deletions src/Extend/SitesLinkedToMagentoStores.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected function getSavedSites()
return Cache::rememberForever('statamic_sites', function () {
$sites = [];
$stores = Rapidez::getStores();
$staticPaths = collect();
$configModel = config('rapidez.models.config');

foreach ($stores as $store) {
Expand All @@ -55,7 +56,13 @@ protected function getSavedSites()
'group' => $store['website_code'] ?? ''
]
];

if (config('statamic.static_caching.strategy') === 'full') {
$staticPaths->put($store['code'], public_path('static') . '/' . str($url)->replace('https://', '')->replaceLast('/', '')->value());
}
}

config(['statamic.static_caching.strategies.full.path' => $staticPaths->toArray()]);

return $sites ?: $this->getFallbackConfig();
});
Expand Down
8 changes: 7 additions & 1 deletion src/RapidezStatamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function nav(string $tag): array
'You can only use a nav tag to get a navigation tree.'
);

return Cache::rememberForever($tag . '-' . config('rapidez.store'), fn() => $this->buildMenu($tag));
return Cache::rememberForever($tag . '-tree-' . config('rapidez.store'), fn() => $this->buildMenu($tag));
}

protected function buildMenu(string $key): array
Expand Down Expand Up @@ -90,6 +90,12 @@ public function determineEntryUrl(Entry|Page|string $entry, string $nav = 'globa
default => '',
};

if (!isset($entry->{$linkedRunwayResourceKey}['url_path'])) {
$this->navCache[$nav][$entry->id()] = '';

return '';
}

$this->navCache[$nav][$entry->id()] = '/' . $entry->{$linkedRunwayResourceKey}['url_path'] . $suffix;

Cache::forever($cacheKey, $this->navCache[$nav]);
Expand Down
6 changes: 6 additions & 0 deletions src/RapidezStatamicServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rapidez\Statamic;

use Illuminate\Foundation\Bootstrap\BootProviders;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
Expand Down Expand Up @@ -48,6 +49,11 @@ public function register()
$router = app(Router::class);
$router->pushMiddlewareToGroup('web', StaticCache::class);
});
$this->app->afterBootstrapping(BootProviders::class, function () {
// Prevent infinite locks by removing the static cache from the statamic.web middleware.
$router = app(Router::class);
$router->removeMiddlewareFromGroup('statamic.web', StaticCache::class);
});
}

public function boot()
Expand Down

0 comments on commit 7e15cf4

Please sign in to comment.