src/Controller/Frontend/WidgetIframeController.php line 63

Open in your IDE?
  1. <?php
  2. /**
  3.  * User: remmel
  4.  * Date: 7/28/15
  5.  * Time: 10:32 AM
  6.  */
  7. namespace App\Controller\Frontend;
  8. use App\Entity\model\Conveyance;
  9. use App\Repository\StopRepository;
  10. use App\Service\UrlRewrite;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. class WidgetIframeController extends AbstractController {
  17.     const BUILD_MANIFEST_JSON "build/manifest.json";
  18.     /**
  19.      * Widget page
  20.      * @Route("/widget/iframe", name="widget_iframe")
  21.      * @Template("Default/homepage/iframe_page.html.twig")
  22.      */
  23.     public function widgetIframeAction(Request $requestUrlRewrite $urlRewriteStopRepository $stopRepo){
  24.         $source $request->query->get('source');
  25.         $type $request->query->get('type');
  26.         $company $request->query->get('company');
  27.         $color $request->query->get('color');
  28.         $isRedirect 'true' === $request->query->get('redirect');
  29.         $depStopId $request->query->get('depStopId');
  30.         $arrStopId $request->query->get('arrStopId');
  31.         $depStop $depStopId $stopRepo->find($depStopId) : null//TODO check if could be directly set by symfony
  32.         $arrStop $arrStopId $stopRepo->find($arrStopId) : null;
  33.         return [
  34.             'source' => isset($source) ? "&source=$sourcenull//TODO should not work anymore
  35.             'type' => json_encode($type),
  36.             'odpage' => $urlRewrite->generateODWebappLink(Conveyance::BUS), //TODO improve that
  37.             'company' => json_encode($company),
  38.             'color' => $color && preg_match('/^[a-f0-9]{6}$/i'$color) ? "#$colornull,
  39.             'search' => [
  40.                 'depStopName' => $depStop $depStop->getName() : null,
  41.                 'arrStopName' => $arrStop $arrStop->getName() : null,
  42.                 'depStopId' => $depStopId,
  43.                 'arrStopId' => $arrStopId,
  44.             ],
  45.             'redirect' => $isRedirect OdController::REDIRECT_TAB OdController::REDIRECT_NONE
  46.         ];
  47.     }
  48.     /**
  49.      * Micro widget / displays the widget
  50.      * @Route("/widget/iframe2", name="widget_iframe2")
  51.      * @Template("Default/homepage/iframe_simple_page.html.twig")
  52.      */
  53.     public function microwidgetIframeAction(Request $request){
  54.     }
  55.     /**
  56.      * Micro widget search / post
  57.      * @Route("/widget/iframe2/search", name="widget_iframe2_post")
  58.      * @ParamConverter("depLat", converter="querystring")
  59.      * @ParamConverter("depLng", converter="querystring")
  60.      * @ParamConverter("arrLat", converter="querystring")
  61.      * @ParamConverter("arrLng", converter="querystring")
  62.      * @ParamConverter("date", converter="querystring")
  63.      */
  64.     public function microwidgetIframePostAction(UrlRewrite $urlRewrite$depLat$depLng$arrLat$arrLng$dateStopRepository $stopRepo){
  65.         $depStop $stopRepo->findOneByLatLon($depLat$depLng);
  66.         $arrStop $stopRepo->findOneByLatLon($arrLat$arrLng);
  67.         $uri '';
  68.         if($depStop && $arrStop) {
  69.             $uri $urlRewrite->generateFromAtoBUrl($depStop$arrStop$datenullfalsenullConveyance::ALL);
  70.         } else {
  71.             $uri =  $this->generateUrl('homepageLocale');
  72.         }
  73.         return $this->redirect($uri);
  74.     }
  75.     /**
  76.      * Redirection as the blog need to use static link to the cb-widget.js file
  77.      * Similar to CKeditorController.assertAction
  78.      * @Route("/js/dist/cb-widget.js", name="widget_fulljs_redirect", options={"i18n"=false})
  79.      */
  80.     public function fulljswidget() {
  81.         $manifest self::getManifest();
  82.         return $this->redirect($manifest['build/cb-widget.js']);
  83.     }
  84.     /**
  85.      * @Route("/js/dist/cb-widget.css", name="widget_fullcss_redirect", options={"i18n"=false})
  86.      */
  87.     public function fullcsswidget() {
  88.         $manifest self::getManifest();
  89.         return $this->redirect($manifest['build/cb-widget.css']);
  90.     }
  91.     /**
  92.      * @Route("/debug/testfulljswidget", options={"i18n"=false})
  93.      * @Template("Default/simple/widget_js.html.twig")
  94.      */
  95.     public function testfulljswidget() {
  96.         return [];
  97.     }
  98.     public static function getManifest(): array {
  99.         //information also in framework.yaml
  100.         return json_decode(file_get_contents(self::BUILD_MANIFEST_JSON), true);
  101.     }
  102. }