bundles/DataprivacyBundle/Controller/DefaultController.php line 16

Open in your IDE?
  1. <?php
  2. namespace DataprivacyBundle\Controller;
  3. use MultilingualBundle\Service\DocumentLookupService;
  4. use Pimcore\Controller\FrontendController;
  5. use Pimcore\Model\Document;
  6. use Pimcore\Model\Document\Service;
  7. use Pimcore\Tool\Authentication;
  8. use DataprivacyBundle\Helper\Configurationhelper;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class DefaultController extends FrontendController
  14. {
  15.     public function defaultAction(Request $requestDocumentLookupService $inotherlang)
  16.     {
  17.         if(\Pimcore\Model\Site::isSiteRequest()) {
  18.             $site \Pimcore\Model\Site::getCurrentSite()->getId();
  19.         } else {
  20.             $site 'default';
  21.         }
  22.         $configuration Configurationhelper::getConfigurationForSite($site);
  23.         //Make replacements for locales
  24.         foreach($configuration as $key => $value){
  25.             if(strpos($value,'%locale%')){
  26.                 $configuration[$key] = str_replace('%locale%',$request->getLocale(),$value);
  27.             }
  28.         }
  29.         if(is_numeric($configuration['privacyUrl'])){
  30.             // Add MultilangBundle to fetch privacy link
  31.             $currentLanguage $request->attributes->get('_locale');
  32.             $privacyDocumentId $configuration['privacyUrl'];
  33.             $document Document::getById($privacyDocumentId);
  34.             $getPrivacyDoc $inotherlang->getLocalizedDocument($document$currentLanguage);
  35.             $configuration['privacyUrl'] = $getPrivacyDoc->getFullPath();
  36.         }
  37.         return $this->render('@Dataprivacy/default/default.html.twig', [
  38.             'configuration' => $configuration
  39.         ]);
  40.     }
  41. }