<?php
/**
* Elements DeMI
*
* This source file is available under the elements DeMI license version 1
*
* @copyright Copyright (c) elements.at New Media Solutions GmbH (https://www.elements.at/)
* @license elements DeMI Lizenz Version 1 (https://www.elements.at/de/demi-lizenz)
*/
namespace Elements\Bundle\DemiFrontendBundle\Controller;
use Elements\Demi\Frontend\Service\Configuration;
use Elements\Demi\Model\AccommodationServiceProvider;
use Elements\Demi\Model\HousePackageMaster;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ContentController extends AbstractDemiController
{
public function __construct(Configuration $configuration)
{
$this->setConfiguration($configuration);
}
public function contentAction(Request $request)
{
$document = $this->document ?? $request->attributes->get('contentDocument');
if (empty($this->configuration->getCurrentDocument())) {
$this->configuration->setDocument($document);
}
$viewParams["language"] = $request->get('language');
if ($document->getTemplate()) {
//this is for project BC - it seems sometimes the content action was used for snippets, with auto view rendering that worked
return $this->renderTemplate($document->getTemplate(), $viewParams);
}
return $this->renderTemplate('@ElementsDemiFrontend/Content/content.html.twig', $viewParams);
}
public function enquireThankYouAction(Request $request): Response
{
if (empty($this->configuration->getCurrentDocument())) {
$this->configuration->setDocument($this->document ?? $request->attributes->get('contentDocument'));
}
$viewParams["language"] = $request->get('language');
$viewParams["accommodation"] = AccommodationServiceProvider::getById($request->get('id'));
if ($request->get('pid')) {
$viewParams["package"] = HousePackageMaster::getById($request->get('pid'));
}
return $this->renderTemplate('@ElementsDemiFrontend/Content/enquireThankYou.html.twig', $viewParams);
}
public function savingRequestThankYouAction(Request $request): Response
{
if (empty($this->configuration->getCurrentDocument())) {
$this->configuration->setDocument($this->document ?? $request->attributes->get('contentDocument'));
}
return $this->renderTemplate('@ElementsDemiFrontend/Content/savingRequestThankYou.html.twig');
}
public function thxAction(Request $request): Response
{
if (empty($this->configuration->getCurrentDocument())) {
$this->configuration->setDocument($this->document ?? $request->attributes->get('contentDocument'));
}
$viewParams = array_map(static function ($a) {
return in_array($a, ["isMobile", "backUrl", "order", "editmode"]);
}, array_keys($request->query->all()));
return $this->renderTemplate('@ElementsDemiFrontend/Includes/snippets/thx.html.twig', $viewParams);
}
public function accountInfoAction(Request $request): Response
{
if (empty($this->configuration->getCurrentDocument())) {
$this->configuration->setDocument($this->document ?? $request->attributes->get('contentDocument'));
}
return $this->renderTemplate('@ElementsDemiFrontend/Content/accountInfo.html.twig');
}
}