vendor/pimcore/portal-engine/src/Controller/PortalController.php line 26

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under following license:
  6.  * - Pimcore Commercial License (PCL)
  7.  *
  8.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  9.  *  @license    http://www.pimcore.org/license     PCL
  10.  */
  11. namespace Pimcore\Bundle\PortalEngineBundle\Controller;
  12. use Pimcore\Bundle\PortalEngineBundle\Service\Document\LanguageVariantService;
  13. use Pimcore\Bundle\PortalEngineBundle\Service\PortalConfig\DefaultValuesService;
  14. use Pimcore\Bundle\PortalEngineBundle\Service\PortalConfig\FrontendBuildService;
  15. use Pimcore\Bundle\PortalEngineBundle\Service\PortalConfig\PortalConfigService;
  16. use Pimcore\Bundle\PortalEngineBundle\Service\Security\SecurityService;
  17. use Pimcore\Http\Request\Resolver\DocumentResolver;
  18. use Symfony\Component\HttpFoundation\RedirectResponse;
  19. use Symfony\Component\HttpFoundation\Request;
  20. class PortalController extends AbstractSiteController
  21. {
  22.     public function pageAction(
  23.         Request $request,
  24.         DocumentResolver $documentResolver,
  25.         DefaultValuesService $defaultConfigService,
  26.         FrontendBuildService $frontendBuildService,
  27.         PortalConfigService $portalConfigService,
  28.         LanguageVariantService $languageVariantService,
  29.         SecurityService $securityService
  30.     ) {
  31.         $defaultConfigService->setPortalPageDefaultConfig($documentResolver->getDocument($request));
  32.         if (!$this->editmode && !$request->get('pimcore_preview') && $portalConfigService->getCurrentPortalConfig()->getEnableLanguageRedirect()) {
  33.             $mapping $languageVariantService->getPortalLanguageVariantsMapping();
  34.             $languages array_keys($mapping);
  35.             $preferredLanguage in_array($securityService->getPortalUser()->getPreferredLanguage(), $languages)
  36.                 ? $securityService->getPortalUser()->getPreferredLanguage()
  37.                 : $request->getPreferredLanguage($languages);
  38.             return new RedirectResponse($mapping[$preferredLanguage]);
  39.         }
  40.         $customizedFrontendBuilds = [[null'-']];
  41.         foreach ($frontendBuildService->getCustomizedFrontendBuilds() as $build) {
  42.             $customizedFrontendBuilds[] = [$build$build];
  43.         }
  44.         return $this->renderTemplate('@PimcorePortalEngine/portal/page.html.twig', [
  45.             'customizedFrontendBuilds' => $customizedFrontendBuilds
  46.         ]);
  47.     }
  48.     public function contentAction()
  49.     {
  50.         return $this->renderTemplate('@PimcorePortalEngine/portal/content.html.twig');
  51.     }
  52. }