<?php
namespace App\Controller\BaseSite\Cronjobs;
use App\Entity\Shop\Log\TrafficLog;
use App\Repository\BaseSite\DomainRepository;
use App\Repository\Shop\Log\TrafficLogRepository;
use App\Repository\Shop\Shop\ShopRepository;
use App\Service\Util\ArvanCDN;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class ShopWatcherCronjobsController extends AbstractController
{
#[Route('/base-site/cronjobs/shop-watcher/activity', name: 'app_base_site_cronjobs_shop_watcher_activity')]
public function app_base_site_cronjobs_shop_watcher_activity(ShopRepository $shopRepository, EntityManagerInterface $entityManager, TrafficLogRepository $trafficLogRepository): JsonResponse
{
foreach ($shopRepository->findAll() as $shopObject) {
if (!$shopObject->isActive()) {
$shopObject->setActive(0);
}
if ($shopObject->getExpiredAt() < new \DateTime('now')) {
$shopObject->setActive(0);
}
}
$entityManager->flush();
return $this->json(['res' => true]);
}
}