refactor sitemap generation and navigation handling; remove old GenerateSitemap command, update to use tasks for better organization, and enhance navigation data retrieval

This commit is contained in:
F4ilji
2025-07-18 13:07:51 +05:00
parent 1257cd552c
commit 0874d3e6b5
28 changed files with 461 additions and 475 deletions
@@ -0,0 +1,44 @@
<?php
namespace App\Containers\AppStructure\Actions;
use App\Containers\AppStructure\Models\Page;
use App\Containers\AppStructure\Tasks\FindPageByPathTask;
use App\Containers\AppStructure\UI\WEB\Transformers\PageResource;
use App\Ship\Contracts\SeoServiceInterface;
use Inertia\Response;
class RenderPageAction
{
public function __construct(readonly SeoServiceInterface $seoPageProvider, readonly FindPageByPathTask $findPageByPathTask){}
public function run(string $path): Response
{
$page = $this->findPageByPathTask->run($path);
$this->handleCheckNotFoundStatusCode($page);
$subSectionPages = $page->section ? PageResource::collection($page->section->pages) : null;
$seo = $this->seoPageProvider->getSeoForModel($page);
$pageResource = new PageResource($page);
$this->handlePageStatusCode($pageResource);
return inertia()->render('Page', [
'page' => $pageResource,
'subSectionPages' => $subSectionPages,
'seo' => $seo,
]);
}
private function handlePageStatusCode(PageResource $pageResource): void
{
if ($pageResource->code != 200) {
abort($pageResource->code);
}
}
private function handleCheckNotFoundStatusCode($page): void
{
if ($page === null) {
abort(404);
}
}
}