/** * Displays a preview file * * @param string $elementType * @param string $key * * @return string|Response */ public function showElementAction($elementType, $key) { try { $element = $this->elementTypesModel->getElement($key, $elementType); if (null === $element || $element->isHidden()) { throw new NotFoundHttpException("Element '{$key}' of type '{$elementType}' not found."); } $templateSuffix = $this->elementTypesModel->isFullPageElementType($elementType) ? "_fullpage" : ""; return $this->twig->render("@core/show_element{$templateSuffix}.twig", ["element" => $element]); } catch (\InvalidArgumentException $e) { throw new NotFoundHttpException("Unknown element type '{$elementType}'.", $e); } }