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

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 Pimcore\Model\Document\PageSnippet;
  19. use Symfony\Component\HttpFoundation\RedirectResponse;
  20. use Symfony\Component\HttpFoundation\Request;
  21. class PortalController extends AbstractSiteController
  22. {
  23.     public function pageAction(
  24.         Request $request,
  25.         DocumentResolver $documentResolver,
  26.         DefaultValuesService $defaultConfigService,
  27.         FrontendBuildService $frontendBuildService,
  28.         PortalConfigService $portalConfigService,
  29.         LanguageVariantService $languageVariantService,
  30.         SecurityService $securityService
  31.     ) {
  32.         $document $documentResolver->getDocument($request);
  33.         if (!$document instanceof PageSnippet) {
  34.             throw new \Exception('Invalid Document');
  35.         }
  36.         $defaultConfigService->setPortalPageDefaultConfig($document);
  37.         if (!$this->editmode && !$request->get('pimcore_preview') && $portalConfigService->getCurrentPortalConfig()->getEnableLanguageRedirect()) {
  38.             $mapping $languageVariantService->getPortalLanguageVariantsMapping();
  39.             $languages array_keys($mapping);
  40.             $preferredLanguage in_array($securityService->getPortalUser()->getPreferredLanguage(), $languages)
  41.                 ? $securityService->getPortalUser()->getPreferredLanguage()
  42.                 : $request->getPreferredLanguage($languages);
  43.             return new RedirectResponse($mapping[$preferredLanguage]);
  44.         }
  45.         $customizedFrontendBuilds = [[null'-']];
  46.         foreach ($frontendBuildService->getCustomizedFrontendBuilds() as $build) {
  47.             $customizedFrontendBuilds[] = [$build$build];
  48.         }
  49.         $oidcEnabled class_exists('Pimcore\\Bundle\\OpenIdConnectBundle\\PimcoreOpenIdConnectBundle');
  50.         return $this->renderTemplate('@PimcorePortalEngine/portal/page.html.twig', [
  51.             'customizedFrontendBuilds' => $customizedFrontendBuilds,
  52.             'oidcEnabled' => $oidcEnabled
  53.         ]);
  54.     }
  55.     public function contentAction()
  56.     {
  57.         return $this->renderTemplate('@PimcorePortalEngine/portal/content.html.twig');
  58.     }
  59. }