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
48 changes: 0 additions & 48 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -4291,18 +4291,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/CFP/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$submittedBy of method AppBundle\\\\Event\\\\Model\\\\TalkInvitation\\:\\:setSubmittedBy\\(\\) expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/CFP/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$talkId of method AppBundle\\\\Event\\\\Model\\\\TalkInvitation\\:\\:setTalkId\\(\\) expects int, int\\|null given\\.$#',
'identifier' => 'argument.type',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Controller/Event/CFP/EditAction.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$eventSlug of method AppBundle\\\\Controller\\\\Event\\\\EventActionHelper\\:\\:getEvent\\(\\) expects string, mixed given\\.$#',
'identifier' => 'argument.type',
Expand Down Expand Up @@ -5473,12 +5461,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TalkAdminType.php',
];
$ignoreErrors[] = [
'message' => '#^Class AppBundle\\\\Event\\\\Form\\\\TalkInvitationType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Form/TalkInvitationType.php',
];
$ignoreErrors[] = [
'message' => '#^Class AppBundle\\\\Event\\\\Form\\\\TalkType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#',
'identifier' => 'missingType.generics',
Expand Down Expand Up @@ -6697,36 +6679,6 @@
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/SponsorTicketRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TalkInvitationRepository\\:\\:getPendingInvitationsByTalkId\\(\\) has parameter \\$talkId with no type specified\\.$#',
'identifier' => 'missingType.parameter',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkInvitationRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TalkInvitationRepository\\:\\:getPendingInvitationsByTalkId\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/TalkInvitationRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TalkInvitationRepository\\:\\: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/TalkInvitationRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\TalkInvitationRepository\\:\\: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/TalkInvitationRepository.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/TalkInvitationRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'\\.aggregation\' on mixed\\.$#',
'identifier' => 'offsetAccess.nonOffsetAccessible',
Expand Down
18 changes: 9 additions & 9 deletions sources/AppBundle/Controller/Event/CFP/EditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
use AppBundle\Controller\Event\EventActionHelper;
use AppBundle\Event\Form\TalkInvitationType;
use AppBundle\Event\Form\TalkType;
use AppBundle\Event\Entity\TalkInvitation;
use AppBundle\Event\Enum\TalkInvitationState;
use AppBundle\Event\Model\GithubUser;
use AppBundle\Event\Model\Repository\SpeakerRepository;
use AppBundle\Event\Model\Repository\TalkInvitationRepository;
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Repository\VoteRepository;
use AppBundle\Event\Model\Talk;
use AppBundle\Event\Model\TalkInvitation;
use AppBundle\Event\Entity\Repository\TalkInvitationRepository;
use AppBundle\Event\Talk\InvitationFormHandler;
use AppBundle\Event\Talk\TalkFormHandler;
use AppBundle\Security\Authentication;
Expand Down Expand Up @@ -95,7 +96,7 @@ public function __invoke(Request $request): RedirectResponse|Response
'event' => $event,
'form' => $talkForm->createView(),
'talk' => $talk,
'invitations' => $this->talkInvitationRepository->getPendingInvitationsByTalkId($talk->getId()),
'invitations' => $this->talkInvitationRepository->getPendingInvitationsByTalkId($talkId),
'speakers' => $this->speakerRepository->getSpeakersByTalk($talk),
'invitationForm' => $invitationForm->createView(),
'votes' => $this->voteRepository->getVotesByTalkWithUser($talk->getId()),
Expand All @@ -106,12 +107,11 @@ public function __invoke(Request $request): RedirectResponse|Response
private function createInvitationForm(GithubUser $user, Talk $talk): FormInterface
{
$invitation = new TalkInvitation();
$invitation
->setSubmittedBy($user->getId())
->setSubmittedOn(new DateTime())
->setToken(base64_encode(random_bytes(30)))
->setState(TalkInvitation::STATE_PENDING)
->setTalkId($talk->getId());
$invitation->submittedBy = (int) $user->getId();
$invitation->submittedOn = new DateTime();
$invitation->token = base64_encode(random_bytes(30));
$invitation->state = TalkInvitationState::Pending;
$invitation->talkId = (int) $talk->getId();

return $this->createForm(TalkInvitationType::class, $invitation);
}
Expand Down
10 changes: 5 additions & 5 deletions sources/AppBundle/Controller/Event/CFP/InviteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use AppBundle\CFP\SpeakerFactory;
use AppBundle\Controller\Event\EventActionHelper;
use AppBundle\Event\Model\Repository\TalkInvitationRepository;
use AppBundle\Event\Entity\Repository\TalkInvitationRepository;
use AppBundle\Event\Model\Repository\TalkRepository;
use AppBundle\Event\Model\Repository\TalkToSpeakersRepository;
use AppBundle\Event\Model\TalkInvitation;
use AppBundle\Event\Enum\TalkInvitationState;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -31,7 +31,7 @@ public function __invoke(Request $request): RedirectResponse
$event = $this->eventActionHelper->getEvent($request->attributes->get('eventSlug'));
$token = $request->attributes->get('token');
$talkId = (int) $request->attributes->get('talkId');
$invitation = $this->talkInvitationRepository->get(['talk_id' => $talkId, 'token' => $token]);
$invitation = $this->talkInvitationRepository->findOneBy(['talkId' => $talkId, 'token' => $token]);
$talk = $this->talkRepository->get($talkId);

if ($invitation === null || $talk === null || $talk->getForumId() !== $event->getId()) {
Expand All @@ -49,8 +49,8 @@ public function __invoke(Request $request): RedirectResponse
]);
}

if ($invitation->getState() === TalkInvitation::STATE_PENDING) {
$invitation->setState(TalkInvitation::STATE_ACCEPTED);
if ($invitation->state === TalkInvitationState::Pending) {
$invitation->state = TalkInvitationState::Accepted;
$this->addFlash('success', $this->translator->trans('Vous etes désormais co-conférencier !'));
// Save co-speaker
$this->talkInvitationRepository->save($invitation);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace AppBundle\Event\Entity\Repository;

use AppBundle\Doctrine\EntityRepository;
use AppBundle\Event\Entity\TalkInvitation;
use AppBundle\Event\Enum\TalkInvitationState;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends EntityRepository<TalkInvitation>
*/
final class TalkInvitationRepository extends EntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, TalkInvitation::class);
}

/**
* @return list<TalkInvitation>
*/
public function getPendingInvitationsByTalkId(int $talkId): array
{
($queryBuilder = $this->createQueryBuilder('i'))
->where($queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('i.talkId', ':talkId'),
$queryBuilder->expr()->eq('i.state', ':state'),
))
->setParameter('talkId', $talkId)
->setParameter('state', TalkInvitationState::Pending);

return $queryBuilder->getQuery()->getResult();
}
}
37 changes: 37 additions & 0 deletions sources/AppBundle/Event/Entity/TalkInvitation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace AppBundle\Event\Entity;

use AppBundle\Event\Entity\Repository\TalkInvitationRepository;
use AppBundle\Event\Enum\TalkInvitationState;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: TalkInvitationRepository::class)]
#[ORM\Table(name: 'afup_sessions_invitation')]
class TalkInvitation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
public ?int $id = null;

#[ORM\Column(name: 'talk_id', nullable: false)]
public int $talkId;

#[ORM\Column(nullable: false, enumType: TalkInvitationState::class)]
public TalkInvitationState $state = TalkInvitationState::Pending;

#[ORM\Column(name: 'submitted_on', nullable: false)]
public \DateTime $submittedOn;

#[ORM\Column(name: 'submitted_by', nullable: false)]
public int $submittedBy;

#[ORM\Column(length: 255, nullable: false)]
public string $token;

#[ORM\Column(length: 255, nullable: false)]
public string $email;
}
11 changes: 11 additions & 0 deletions sources/AppBundle/Event/Enum/TalkInvitationState.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace AppBundle\Event\Enum;

enum TalkInvitationState: int
{
case Pending = 0;
case Accepted = 1;
}
12 changes: 12 additions & 0 deletions sources/AppBundle/Event/Form/TalkInvitationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

namespace AppBundle\Event\Form;

use AppBundle\Event\Entity\TalkInvitation;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @extends AbstractType<TalkInvitation>
*/
class TalkInvitationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand All @@ -18,4 +23,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('save', SubmitType::class, ['label' => 'Inviter'])
;
}

public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => TalkInvitation::class,
]);
}
}

This file was deleted.

Loading
Loading