12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Http\Request;
- use Symfony\Component\HttpFoundation\Response;
- use App\Helpers\SiteCache;
- use App\Services\TemplateUpdater;
- use App\Services\LiquidRenderer;
- class LoadDistData
- {
-
- public function handle(Request $request, Closure $next): Response
- {
-
- $domain = getHost();
-
- $dist = SiteCache::getDist($domain);
- $dist = $dist ? unserialize($dist) : null;
-
- if (!$dist) {
- abort(404, 'site not found.');
- }
-
- if(!empty($dist?->publishList?->template_update_code)) {
- if (
- !$dist?->publishList?->template_local_code ||
- $dist?->publishList?->template_update_code !== $dist?->publishList?->template_local_code
- ) {
-
-
- TemplateUpdater::updateTemplates($dist);
-
- SiteCache::clearDistCache($domain);
- $dist = SiteCache::getDist($domain);
- $dist = $dist ? unserialize($dist) : null;
- if (!$dist) {
- abort(404, 'site not found.');
- }
- }
- }
-
- app()->instance('dist', $dist);
-
-
- $menus_header=SiteCache::getMenu($domain,0,$dist->id);
- $menus_footer=SiteCache::getMenu($domain,1,$dist->id);
- app()->instance('menus_header', $menus_header);
- app()->instance('menus_footer', $menus_footer);
- return $next($request);
- }
- }
|