1
0

Refactoring

This commit is contained in:
Richard Dern 2024-05-08 17:40:24 +02:00
parent 43cf565f8f
commit 343d372aa8
3 changed files with 14 additions and 7 deletions

View File

@ -44,17 +44,17 @@ public function render()
$this->prepareRender($currentPage); $this->prepareRender($currentPage);
if ($currentPage === 1) { if ($currentPage === 1) {
$result[$this->bundle->getPath()] = (string) view('article', $this->viewData); $result[$this->bundle->getPath()] = $this->renderView();
} }
$page = sprintf('%spage/%s/', $this->bundle->getPath(), $currentPage); $page = sprintf('%spage/%s/', $this->bundle->getPath(), $currentPage);
$result[$page] = (string) view('article', $this->viewData); $result[$page] = $this->renderView();
} }
} else { } else {
$this->prepareRender(1); $this->prepareRender(1);
$result[$this->bundle->getPath()] = (string) view('article', $this->viewData); $result[$this->bundle->getPath()] = $this->renderView();
} }
return $result; return $result;
@ -67,7 +67,7 @@ public function renderCard()
{ {
$this->prepareRenderCard(); $this->prepareRenderCard();
return view('article-card', $this->viewData); return $this->renderView('article-card');
} }
/** /**
@ -214,4 +214,11 @@ protected function collectSubBundles()
return $subBundles; return $subBundles;
} }
protected function renderView(?string $view = 'article')
{
$html = (string) view($view, $this->viewData);
return $html;
}
} }

View File

@ -20,7 +20,7 @@ public function render()
data_set($this->viewData, 'showToc', true); data_set($this->viewData, 'showToc', true);
data_set($this->viewData, 'dossier', $dossier); data_set($this->viewData, 'dossier', $dossier);
return [$this->bundle->getPath() => (string) view('article', $this->viewData)]; return [$this->bundle->getPath() => $this->renderView()];
} }
/** /**
@ -30,7 +30,7 @@ public function renderCard()
{ {
$this->prepareRenderCard(); $this->prepareRenderCard();
return view('dossier-card', $this->viewData); return $this->renderView('dossier-card');
} }
/** /**

View File

@ -27,7 +27,7 @@ public function render()
data_set($this->viewData, 'relations', $relations); data_set($this->viewData, 'relations', $relations);
return [$this->bundle->getPath() => (string) view('term', $this->viewData)]; return [$this->bundle->getPath() => $this->renderView('term')];
} }
/** /**