src/Rhyme/WMassArtsHub/Controller/ApiTestingController.php line 25

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2021 Rhyme Digital LLC (https://rhyme.digital)
  4.  *
  5.  * @license LGPL-3.0-or-later
  6.  */
  7. namespace Rhyme\WMassArtsHub\Controller;
  8. use Contao\System;
  9. use Rhyme\WMassArtsHub\Frontend\Controller\ProfileImportController;
  10. use Rhyme\WMassArtsHub\Model\Feed;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Contao\CoreBundle\Controller\AbstractController;
  14. /**
  15.  * Handles custom scripts
  16.  * *
  17.  * @Route("/apitest", defaults={"_scope" = "frontend", "_token_check" = true})
  18.  */
  19. class ApiTestingController extends AbstractController
  20. {
  21.     /**
  22.      * Handles custom script responses
  23.      *
  24.      * @return Response
  25.      *
  26.      * @Route("/profile", name="rhyme_creativeground_profile")
  27.      */
  28.     public function profileAction()
  29.     {
  30.         $this->initializeContaoFramework();
  31.         $controller = new ProfileImportController();
  32.         return $controller->run();
  33.     }
  34.     /**
  35.      * Handles custom script responses
  36.      *
  37.      * @return Response
  38.      *
  39.      * @Route("/events", name="rhyme_creativeground_eventstest")
  40.      */
  41.     public function eventSyncTestAction()
  42.     {
  43.         $this->initializeContaoFramework();
  44.         //TODO - Create a findPublished method on the model
  45.         $objFeeds Feed::findByPublished('1');
  46.         if($objFeeds !== null) {
  47.             while($objFeeds->next()) {
  48.                 if ($objFeeds->type === 'eventbrite' && isset($GLOBALS['ARTSHUB_FEED_CONFIGS']) && \is_array($GLOBALS['ARTSHUB_FEED_CONFIGS'][$objFeeds->type])) {
  49.                     $callback $GLOBALS['ARTSHUB_FEED_CONFIGS'][$objFeeds->type];
  50.                     System::importStatic($callback[0])->{$callback[1]}($objFeeds->current());
  51.                 }
  52.             }
  53.         }
  54.         return new Response('Done');
  55.     }
  56. }