vendor/pimcore/data-hub/src/Controller/GraphQLExplorerController.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Bundle\DataHubBundle\Controller;
  15. use Pimcore\Bundle\DataHubBundle\Service\CheckConsumerPermissionsService;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\Routing\RouterInterface;
  19. class GraphQLExplorerController extends AbstractController
  20. {
  21.     /**
  22.      * @param RouterInterface $routingService
  23.      * @param Request $request
  24.      *
  25.      * @return \Symfony\Component\HttpFoundation\Response
  26.      *
  27.      * @throws \Exception
  28.      */
  29.     public function explorerAction(RouterInterface $routingServiceRequest $request)
  30.     {
  31.         $urlParams array_merge($request->request->all(), $request->query->all());
  32.         $clientName $request->get('clientname');
  33.         $url $routingService->generate('admin_pimcoredatahub_webservice', ['clientname' => $clientName]);
  34.         if (!$url) {
  35.             throw new \Exception('unable to resolve');
  36.         }
  37.         if ($urlParams) {
  38.             $url $url '?' http_build_query($urlParams);
  39.         }
  40.         $response $this->render('@PimcoreDataHub/Feature/explorer.html.twig', [
  41.             'graphQLUrl' => $url,
  42.             'tokenHeader' => CheckConsumerPermissionsService::TOKEN_HEADER
  43.         ]);
  44.         $response->setPublic();
  45.         $response->setExpires(new \DateTime('tomorrow'));
  46.         return $response;
  47.     }
  48. }