Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ twig:
globals:
photo_storage: '@AppBundle\CFP\PhotoStorage'
global_menu_event_label: '%env(AFUP_GLOBAL_MENU_EVENT_LABEL)%'
planning_timezone: !php/const AppBundle\Event\Model\Planning::TIMEZONE
planning_timezone: !php/const AppBundle\Event\Entity\Planning::TIMEZONE
form_themes: ['form_theme.html.twig']
default_path: "%kernel.project_dir%/templates"
150 changes: 0 additions & 150 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1993,42 +1993,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/CFP/ViewModel/EventTalkList.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getEnd\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Calendar/IcsPlanningGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getName\\(\\) on AppBundle\\\\Event\\\\Model\\\\Room\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Calendar/IcsPlanningGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getStart\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Calendar/IcsPlanningGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getEnd\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Calendar/JsonPlanningGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getName\\(\\) on AppBundle\\\\Event\\\\Model\\\\Room\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Calendar/JsonPlanningGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getStart\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Calendar/JsonPlanningGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method setTimezone\\(\\) on DateTime\\|null\\.$#',
'identifier' => 'method.nonObject',
Expand Down Expand Up @@ -2239,18 +2203,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Command/UpdateCompanyMemberStateCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method format\\(\\) on DateTime\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Command/VideosDataCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getStart\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Command/VideosDataCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$messages of method Symfony\\\\Component\\\\Console\\\\Output\\\\OutputInterface\\:\\:writeln\\(\\) expects iterable\\<string\\>\\|string, string\\|false given\\.$#',
'identifier' => 'argument.type',
Expand Down Expand Up @@ -3103,30 +3055,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/DeleteAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getEnd\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getId\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getStart\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method setRoomId\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Controller\\\\Admin\\\\Event\\\\Session\\\\EditAction\\:\\:getForm\\(\\) has parameter \\$roomChoices with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand All @@ -3145,30 +3073,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$data of method AppBundle\\\\Controller\\\\Admin\\\\Event\\\\Session\\\\EditAction\\:\\:getForm\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Planning, AppBundle\\\\Event\\\\Model\\\\Planning\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$entity of method CCMBenchmark\\\\Ting\\\\Repository\\\\Repository\\<AppBundle\\\\Event\\\\Model\\\\Planning\\>\\:\\:save\\(\\) expects AppBundle\\\\Event\\\\Model\\\\Planning, AppBundle\\\\Event\\\\Model\\\\Planning\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$eventId of method AppBundle\\\\Event\\\\Model\\\\Planning\\:\\:setEventId\\(\\) expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$talkId of method AppBundle\\\\Event\\\\Model\\\\Planning\\:\\:setTalkId\\(\\) expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Admin/Event/Session/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Possibly invalid array key type mixed\\.$#',
'identifier' => 'offsetAccess.invalidOffset',
Expand Down Expand Up @@ -5239,12 +5143,6 @@
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Talks/ListAction.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getEventId\\(\\) on AppBundle\\\\Event\\\\Model\\\\Planning\\|null\\.$#',
'identifier' => 'method.nonObject',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Talks/ShowAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\<T of object\\>\\|T of object, string given\\.$#',
'identifier' => 'argument.type',
Expand Down Expand Up @@ -6067,18 +5965,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Lead.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot cast mixed to int\\.$#',
'identifier' => 'cast.int',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Planning.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Planning\\:\\:setId\\(\\) has parameter \\$id with no type specified\\.$#',
'identifier' => 'missingType.parameter',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Planning.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\BadgeRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down Expand Up @@ -6499,30 +6385,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/InvoiceRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\PlanningRepository\\:\\:getByTalk\\(\\) should return AppBundle\\\\Event\\\\Model\\\\Planning\\|null but returns mixed\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/PlanningRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\PlanningRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/PlanningRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\PlanningRepository\\:\\:initMetadata\\(\\) return type with generic class CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/PlanningRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\<object\\>\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/PlanningRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\RoomRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down Expand Up @@ -6733,12 +6595,6 @@
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'planning\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'room\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down Expand Up @@ -6895,12 +6751,6 @@
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#4 \\$planning of class AppBundle\\\\Event\\\\Model\\\\TalkAggregate constructor expects AppBundle\\\\Event\\\\Model\\\\Planning\\|null, mixed given\\.$#',
'identifier' => 'argument.type',
'count' => 2,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'count\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down
18 changes: 14 additions & 4 deletions sources/AppBundle/Calendar/IcsPlanningGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,37 @@

namespace AppBundle\Calendar;

use AppBundle\Event\Entity\Repository\PlanningRepository;
use AppBundle\Event\Model\Event;
use AppBundle\Event\Model\Repository\TalkRepository;
use Sabre\VObject\Component\VCalendar;

class IcsPlanningGenerator
{
public function __construct(private readonly TalkRepository $talkRepository) {}
public function __construct(
private readonly TalkRepository $talkRepository,
private readonly PlanningRepository $planningRepository,
) {}

public function generateForEvent(Event $event): string
{
$talkAggregates = $this->talkRepository->getByEventWithSpeakers($event);
$talkAggregates = $this->planningRepository->enrichTalkAggregates(
$this->talkRepository->getByEventWithSpeakers($event),
);

$events = [];

$vcalendar = new VCalendar($events);
$vcalendar->add('X-WR-CALNAME', $event->getTitle());
foreach ($talkAggregates as $talkAggregate) {
if ($talkAggregate->planning === null || $talkAggregate->room === null) {
continue;
}

$vcalendar->add('VEVENT', [
'SUMMARY' => $talkAggregate->talk->getTitle(),
'DTSTART' => $talkAggregate->planning->getStart(),
'DTEND' => $talkAggregate->planning->getEnd(),
'DTSTART' => $talkAggregate->planning->start,
'DTEND' => $talkAggregate->planning->end,
'DESCRIPTION' => strip_tags(html_entity_decode($talkAggregate->talk->getAbstract())),
'LOCATION' => $talkAggregate->room->getName(),
]);
Expand Down
14 changes: 11 additions & 3 deletions sources/AppBundle/Calendar/JsonPlanningGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace AppBundle\Calendar;

use AppBundle\CFP\PhotoStorage;
use AppBundle\Event\Entity\Repository\PlanningRepository;
use AppBundle\Event\Model\Event;
use AppBundle\Event\Model\Repository\TalkRepository;

class JsonPlanningGenerator
{
public function __construct(
private readonly TalkRepository $talkRepository,
private readonly PlanningRepository $planningRepository,
private readonly PhotoStorage $photoStorage,
) {}

Expand All @@ -20,11 +22,17 @@ public function __construct(
*/
public function generate(Event $event): array
{
$talkAggregates = $this->talkRepository->getByEventWithSpeakers($event);
$talkAggregates = $this->planningRepository->enrichTalkAggregates(
$this->talkRepository->getByEventWithSpeakers($event),
);

$data = [];

foreach ($talkAggregates as $talkAggregate) {
if ($talkAggregate->planning === null || $talkAggregate->room === null) {
continue;
}

$conferenciers = [];
foreach ($talkAggregate->speakers as $speaker) {
$conferenciers[] = [
Expand All @@ -35,8 +43,8 @@ public function generate(Event $event): array
}

$timeZone = new \DateTimeZone("Europe/Paris");
$start = $talkAggregate->planning->getStart()->setTimezone($timeZone);
$end = $talkAggregate->planning->getEnd()->setTimezone($timeZone);
$start = $talkAggregate->planning->start->setTimezone($timeZone);
$end = $talkAggregate->planning->end->setTimezone($timeZone);

$data[] = [
'conferenciers' => $conferenciers,
Expand Down
8 changes: 6 additions & 2 deletions sources/AppBundle/Command/VideosDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace AppBundle\Command;

use AppBundle\Event\Entity\Repository\PlanningRepository;
use AppBundle\Event\Model\Repository\EventRepository;
use AppBundle\Event\Model\Repository\TalkRepository;
use Symfony\Component\Console\Command\Command;
Expand All @@ -15,6 +16,7 @@ class VideosDataCommand extends Command
{
public function __construct(
private readonly TalkRepository $talkRepository,
private readonly PlanningRepository $planningRepository,
private readonly EventRepository $eventRepository,
) {
parent::__construct();
Expand All @@ -36,7 +38,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \InvalidArgumentException("Event not found");
}

$talkAggregates = $this->talkRepository->getByEventWithSpeakers($event);
$talkAggregates = $this->planningRepository->enrichTalkAggregates(
$this->talkRepository->getByEventWithSpeakers($event),
);

$data = [];

Expand All @@ -51,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'title' => sprintf("%s - %s - %s", $talkAggregate->talk->getTitle(), implode(',', $speakersNames), $event->getTitle()),
"language" => $talkAggregate->talk->getLanguageCode(),
'url' => "https://afup.org/talks/" . $talkAggregate->talk->getUrlKey(),
'recording_date' => $talkAggregate->planning->getStart()->format(\Datetime::ISO8601),
'recording_date' => $talkAggregate->planning?->start?->format(\Datetime::ISO8601),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace AppBundle\Controller\Admin\Event\Session;

use AppBundle\Event\Model\Planning;
use AppBundle\Event\Model\Repository\PlanningRepository;
use AppBundle\Event\Entity\Planning;
use AppBundle\Event\Entity\Repository\PlanningRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -16,7 +16,7 @@ public function __construct(private readonly PlanningRepository $planningReposit

public function __invoke(int $id, Request $request): Response
{
$planning = $this->planningRepository->get($id);
$planning = $this->planningRepository->find($id);
if (!$planning) {
throw $this->createNotFoundException('Planning not found: ' . $id);
}
Expand All @@ -26,9 +26,9 @@ public function __invoke(int $id, Request $request): Response
// c'est donc l'heure locale de l'événement, pas celle du navigateur.
$timezone = new \DateTimeZone(Planning::TIMEZONE);

$planning->setStart(new \DateTime($data['start'], $timezone));
$planning->setEnd(new \DateTime($data['end'], $timezone));
$planning->setRoomId((int) $data['roomId']);
$planning->start = new \DateTime($data['start'], $timezone);
$planning->end = new \DateTime($data['end'], $timezone);
$planning->roomId = (int) $data['roomId'];

$this->planningRepository->save($planning);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace AppBundle\Controller\Admin\Event\Session;

use AppBundle\AuditLog\Audit;
use AppBundle\Event\Model\Planning;
use AppBundle\Event\Model\Repository\PlanningRepository;
use AppBundle\Event\Entity\Planning;
use AppBundle\Event\Entity\Repository\PlanningRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -21,7 +21,7 @@ public function __construct(
public function __invoke(Request $request): Response
{
$id = $request->attributes->get('id');
$planning = $this->planningRepository->get($id);
$planning = $this->planningRepository->find($id);
if (!$planning instanceof Planning) {
throw $this->createNotFoundException(sprintf('Planning not found with id "%s".', $id));
}
Expand Down
Loading
Loading