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

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 Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  17. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\Routing\RouterInterface;
  20. class GraphQLExplorerController extends AbstractController
  21. {
  22.     /**
  23.      * @param RouterInterface $routingService
  24.      * @param Request $request
  25.      *
  26.      * @Cache(expires="tomorrow", public=true)
  27.      *
  28.      * @return \Symfony\Component\HttpFoundation\Response
  29.      *
  30.      * @throws \Exception
  31.      */
  32.     public function explorerAction(RouterInterface $routingServiceRequest $request)
  33.     {
  34.         $urlParams array_merge($request->request->all(), $request->query->all());
  35.         $clientName $request->get('clientname');
  36.         $url $routingService->generate('admin_pimcoredatahub_webservice', ['clientname' => $clientName]);
  37.         if (!$url) {
  38.             throw new \Exception('unable to resolve');
  39.         }
  40.         if ($urlParams) {
  41.             $url $url '?' http_build_query($urlParams);
  42.         }
  43.         return $this->render('@PimcoreDataHub/Feature/explorer.html.twig', [
  44.             'graphQLUrl' => $url,
  45.             'tokenHeader' => CheckConsumerPermissionsService::TOKEN_HEADER
  46.         ]);
  47.     }
  48. }