* Weitere Änderungen an der Nicht-/Anzeige von Sidebar-Widgets * Behoben: Umlaute-Problem TT-Suchmaske git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3322 f459cee4-fb09-11de-96c3-f9c5f16c3c76
152 lines
No EOL
5.3 KiB
PHP
152 lines
No EOL
5.3 KiB
PHP
<?php
|
|
/**
|
|
* @author Ulrich Hecht <ulrich.hecht@hecht-software.de>
|
|
* @date 02/22/2017
|
|
*/
|
|
|
|
namespace AppBundle\Controller;
|
|
|
|
|
|
use AppBundle\Entity\Page;
|
|
use AppBundle\Entity\SunstarTravelProgram;
|
|
use AppBundle\Form\TtSearchRequestType;
|
|
use AppBundle\Listener\KernelControllerListener;
|
|
use Doctrine\ORM\EntityManager;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
|
/**
|
|
* Controller for CMS pages. CMS pages are represented by Page instances (i.e. entries of the page database table).
|
|
* The template property of a Page object defines the action method below. If a travel program is assigned then the
|
|
* travelProgramAction is used. If no template is specified, then the defaultAction is used.
|
|
* If there is no action method, the defaultAction is called and the template name is passed as an argument. A twig
|
|
* file with this template will be rendered in this case.
|
|
*
|
|
* The view templates can be found pages/cms.
|
|
*
|
|
* Also see {@link KernelControllerListener}, which handles routing.
|
|
*
|
|
* @package AppBundle\Controller
|
|
*/
|
|
class CmsController extends Controller
|
|
{
|
|
/**
|
|
* @return EntityManager
|
|
*/
|
|
private function getEntityManager()
|
|
{
|
|
return $this->getDoctrine()->getManager();
|
|
}
|
|
|
|
public function defaultAction(Page $page, $template = 'default')
|
|
{
|
|
return $this->render('default/pages/cms/'. $template .'.html.twig', [
|
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
|
'page' => $page,
|
|
]);
|
|
}
|
|
|
|
public function overviewAction(Page $page)
|
|
{
|
|
return $this->render('default/pages/cms/overview.html.twig', [
|
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
|
'page' => $page,
|
|
]);
|
|
}
|
|
|
|
public function travelProgramOverviewAction(Page $page)
|
|
{
|
|
$childPages =
|
|
$this->getEntityManager()->getRepository('AppBundle:Page')->getChildrenWithTravelProgramsAndDates($page);
|
|
|
|
$nonMediated = [];
|
|
$mediated = [];
|
|
foreach ($childPages as $childPage)
|
|
{
|
|
if ($childPage->getStatus() == 1 && $childPage->getTravelProgram() &&
|
|
$childPage->getTravelProgram()->getIsMediated())
|
|
{
|
|
$mediated[] = $childPage;
|
|
}
|
|
else
|
|
{
|
|
$nonMediated[] = $childPage;
|
|
}
|
|
}
|
|
// We only need a separation if there are mediated AND non mediated travel programs
|
|
if (empty($nonMediated) && !empty($mediated))
|
|
{
|
|
$childPages = $mediated;
|
|
}
|
|
else
|
|
{
|
|
$childPages = $nonMediated;
|
|
}
|
|
|
|
return $this->render('default/pages/cms/travelProgramOverview.html.twig', [
|
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
|
'page' => $page,
|
|
'child_pages' => $childPages,
|
|
'mediated_child_pages' => $mediated,
|
|
]);
|
|
}
|
|
|
|
public function traveltainmentAction(Page $page)
|
|
{
|
|
$destination = array_search($page->getBumaDestination(), TtSearchRequestType::$DESTINATION_CHOICES);
|
|
$form = $this->createForm(TtSearchRequestType::class, [
|
|
'topRegion' => $destination ? $destination : null,
|
|
], [
|
|
'country' => $page->getCountry(),
|
|
]);
|
|
|
|
return $this->render('default/pages/cms/traveltainment.html.twig', [
|
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
|
'page' => $page,
|
|
'show_search_sidebar_widget' => false,
|
|
'tt_search_form' => $form->createView(),
|
|
]);
|
|
}
|
|
|
|
public function travelProgramAction(Page $page)
|
|
{
|
|
$this->getDoctrine()->getRepository('AppBundle:TravelPeriod')->getTrueTravelPeriods($page->getTravelProgram());
|
|
|
|
// replace this example code with whatever you need
|
|
return $this->render('default/pages/cms/travelProgram.html.twig', [
|
|
'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
|
|
'page' => $page,
|
|
'show_offers_sidebar_widget' => false,
|
|
'travel_program' => $page->getTravelProgram(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @param Page $page
|
|
*
|
|
* @return \Symfony\Component\HttpFoundation\Response
|
|
*
|
|
* @todo This is actually the same as overview, but with different sidebar. Utilize cmsSettings field of page entity for such requirements
|
|
*/
|
|
public function jugendreisenAction(Page $page)
|
|
{
|
|
return $this->render('default/pages/cms/overview.html.twig', [
|
|
'page' => $page,
|
|
'show_search_sidebar_widget' => false,
|
|
'show_offers_sidebar_widget' => false,
|
|
]);
|
|
}
|
|
|
|
public function sunstarAction(Page $page)
|
|
{
|
|
/** @var SunstarTravelProgram[] $sunstarTravelPrograms */
|
|
$sunstarTravelPrograms = $this->getDoctrine()->getRepository('AppBundle:SunstarTravelProgram')
|
|
->findBy(['destination' => $page->getCmsSettings()]);
|
|
|
|
return $this->render('default/pages/cms/sunstar.html.twig', [
|
|
'page' => $page,
|
|
'show_search_sidebar_widget' => false,
|
|
'show_offers_sidebar_widget' => false,
|
|
'sunstar_travel_programs' => $sunstarTravelPrograms,
|
|
]);
|
|
}
|
|
} |