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

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 Enterprise License (PEL)
  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 PEL
  13.  */
  14. namespace Pimcore\Bundle\DataHubBundle\Controller;
  15. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  16. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\Routing\RouterInterface;
  19. class GraphQLExplorerController extends Controller
  20. {
  21.     /**
  22.      * @param RouterInterface $routingService
  23.      * @param Request $request
  24.      *
  25.      * @Cache(expires="tomorrow", public=true)
  26.      *
  27.      * @return \Symfony\Component\HttpFoundation\Response
  28.      *
  29.      * @throws \Exception
  30.      */
  31.     public function explorerAction(RouterInterface $routingServiceRequest $request)
  32.     {
  33.         $urlParams array_merge($request->request->all(), $request->query->all());
  34.         $clientName $request->get('clientname');
  35.         $route $routingService->getRouteCollection()->get('admin_pimcoredatahub_webservice');
  36.         if ($route) {
  37.             $url $route->getPath();
  38.             $url str_replace('/{clientname}'''$url);
  39.         } else {
  40.             throw new \Exception('unable to resolve');
  41.         }
  42.         if ($clientName) {
  43.             $url .= '/' $clientName;
  44.         }
  45.         if ($urlParams) {
  46.             $url $url '?' http_build_query($urlParams);
  47.         }
  48.         return $this->render('PimcoreDataHubBundle:Feature:explorer.html.twig', [
  49.             'graphQLUrl' => $url,
  50.             'tokenHeader' => 'access-token'
  51.         ]);
  52.     }
  53. }