mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 10:15:41 +00:00
fix: update migration
This commit is contained in:
parent
11c7207a1c
commit
dba098441e
@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
/**
|
/**
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
*/
|
*/
|
||||||
final class Version20240717172250 extends AbstractMigration
|
final class Version20240717182345 extends AbstractMigration
|
||||||
{
|
{
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
19
src/Controller/DomainCalendarController.php
Normal file
19
src/Controller/DomainCalendarController.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Service\RDAPService;
|
||||||
|
use Exception;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
|
class DomainRefreshController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function __invoke(string $ldhName, RDAPService $RDAPService): void
|
||||||
|
{
|
||||||
|
$RDAPService->registerDomains([$ldhName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use App\Entity\Domain;
|
|
||||||
use App\Entity\DomainEntity;
|
|
||||||
use App\Entity\DomainEvent;
|
|
||||||
use App\Repository\DomainRepository;
|
|
||||||
use App\Service\RDAPService;
|
|
||||||
use Eluceo\iCal\Domain\Entity\Attendee;
|
|
||||||
use Eluceo\iCal\Domain\Entity\Calendar;
|
|
||||||
use Eluceo\iCal\Domain\Entity\Event;
|
|
||||||
use Eluceo\iCal\Domain\ValueObject\Category;
|
|
||||||
use Eluceo\iCal\Domain\ValueObject\Date;
|
|
||||||
use Eluceo\iCal\Domain\ValueObject\EmailAddress;
|
|
||||||
use Eluceo\iCal\Domain\ValueObject\SingleDay;
|
|
||||||
use Eluceo\iCal\Presentation\Factory\CalendarFactory;
|
|
||||||
use Exception;
|
|
||||||
use Sabre\VObject\Reader;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
|
|
||||||
|
|
||||||
class TestController extends AbstractController
|
|
||||||
{
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
private readonly DomainRepository $domainRepository
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/test/publish/calendar', name: 'test_publish_calendar')]
|
|
||||||
public function testPublishCalendar(): Response
|
|
||||||
{
|
|
||||||
$calendar = new Calendar();
|
|
||||||
|
|
||||||
|
|
||||||
/** @var Domain $domain */
|
|
||||||
foreach ($this->domainRepository->findAll() as $domain) {
|
|
||||||
$attendees = [];
|
|
||||||
|
|
||||||
/** @var DomainEntity $entity */
|
|
||||||
foreach ($domain->getDomainEntities()->toArray() as $entity) {
|
|
||||||
$vCard = Reader::readJson($entity->getEntity()->getJCard());
|
|
||||||
$email = (string)$vCard->EMAIL;
|
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) continue;
|
|
||||||
|
|
||||||
$attendees[] = (new Attendee(new EmailAddress($email)))->setDisplayName((string)$vCard->FN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var DomainEvent $event */
|
|
||||||
foreach ($domain->getEvents()->toArray() as $event) {
|
|
||||||
$calendar->addEvent((new Event())
|
|
||||||
->setSummary($domain->getLdhName() . ' (' . $event->getAction()->value . ')')
|
|
||||||
->addCategory(new Category($event->getAction()->value))
|
|
||||||
->setAttendees($attendees)
|
|
||||||
->setOccurrence(new SingleDay(new Date($event->getDate())))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Response((new CalendarFactory())->createCalendar($calendar), Response::HTTP_OK, [
|
|
||||||
"Content-Type" => 'text/calendar; charset=utf-8'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user