Skip to content

Commit

Permalink
Adjusted controller
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed Jan 17, 2022
1 parent a562e5d commit f2984b7
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ class RootPageDependentModulesController extends AbstractFragmentController
{
public function __invoke(Request $request, ModuleModel $model, string $section, array $classes = null): Response
{
$pageModel = $this->getPageModel();
$controller = $this->container->get('contao.framework')->getAdapter(Controller::class);
if (!$pageModel = $this->getPageModel()) {
return new Response(''); // This can happen in the back end preview if no module has been selected
}

$modules = StringUtil::deserialize($model->rootPageDependentModules);
$content = '';

if (\is_array($modules) && \array_key_exists($pageModel->rootId, $modules)) {
$content = $controller->getFrontendModule($modules[$pageModel->rootId]);
if (empty($modules) || !\is_array($modules) || !\array_key_exists($pageModel->rootId, $modules)) {
return new Response(''); // No need for further processing if there are no modules
}

$controller = $this->container->get('contao.framework')->getAdapter(Controller::class);
$content = $controller->getFrontendModule($modules[$pageModel->rootId]);

$this->tagResponse($model);

return new Response($content);
Expand Down

0 comments on commit f2984b7

Please sign in to comment.