<?php
/**
* Copyright (c) 2021 Rhyme Digital LLC (https://rhyme.digital)
*
* @license LGPL-3.0-or-later
*/
namespace Rhyme\WMassArtsHub\Controller;
use Contao\System;
use Rhyme\WMassArtsHub\Frontend\Controller\ProfileImportController;
use Rhyme\WMassArtsHub\Model\Feed;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Contao\CoreBundle\Controller\AbstractController;
/**
* Handles custom scripts
* *
* @Route("/apitest", defaults={"_scope" = "frontend", "_token_check" = true})
*/
class ApiTestingController extends AbstractController
{
/**
* Handles custom script responses
*
* @return Response
*
* @Route("/profile", name="rhyme_creativeground_profile")
*/
public function profileAction()
{
$this->initializeContaoFramework();
$controller = new ProfileImportController();
return $controller->run();
}
/**
* Handles custom script responses
*
* @return Response
*
* @Route("/events", name="rhyme_creativeground_eventstest")
*/
public function eventSyncTestAction()
{
$this->initializeContaoFramework();
//TODO - Create a findPublished method on the model
$objFeeds = Feed::findByPublished('1');
if($objFeeds !== null) {
while($objFeeds->next()) {
if ($objFeeds->type === 'eventbrite' && isset($GLOBALS['ARTSHUB_FEED_CONFIGS']) && \is_array($GLOBALS['ARTSHUB_FEED_CONFIGS'][$objFeeds->type])) {
$callback = $GLOBALS['ARTSHUB_FEED_CONFIGS'][$objFeeds->type];
System::importStatic($callback[0])->{$callback[1]}($objFeeds->current());
}
}
}
return new Response('Done');
}
}