Skip to content

Ajout de room_id dans timeSlot#2

Open
JulienSauguesEyraud wants to merge 4 commits into
Orbitale:mainfrom
JulienSauguesEyraud:TimeSlotWithRoom
Open

Ajout de room_id dans timeSlot#2
JulienSauguesEyraud wants to merge 4 commits into
Orbitale:mainfrom
JulienSauguesEyraud:TimeSlotWithRoom

Conversation

@JulienSauguesEyraud
Copy link
Copy Markdown

No description provided.

$room = $request->request->get('room_id');
$event = $request->request->get('event_id');
if($booth && $room) {
if($room != $booth->get('room_id')) {
Copy link
Copy Markdown
Member

@Pierstoval Pierstoval Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Cette ligne renverra toujours false, et une erreur, parce qu'à ce stade du code, $booth contient le contenu de $request->request->get('booth_id') , qui est un scalaire, et pas un objet.
  • Il faut toujours utiliser === ou !== pour comparer la valeur ET le type, ça évite de faire du type juggling : https://www.php.net/manual/fr/language.types.type-juggling.php

Comment thread migrations/Version20260420144514.php Outdated
Comment on lines +35 to +41
$this->addSql('DROP INDEX IDX_75EA56E0FB7336F0E3BD61CE16BA31DBBF396750 ON messenger_messages');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('ALTER TABLE time_slot DROP FOREIGN KEY FK_1B3294A54177093');
$this->addSql('DROP INDEX IDX_1B3294A54177093 ON time_slot');
$this->addSql('ALTER TABLE time_slot DROP room_id');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici, tu peux enlever tout ça : on ne va pas rollback une BDD par ce biais, on créera une nouvelle migration (et donc de nouveaux commits) pour corriger le bug.
Dans d'autres projets, le rollback avec la fonction down() peut être utile, mais en 15 ans je ne l'ai jamais vu utilisé en prod pour le moment 😁

Comment thread migrations/Version20260420144514.php Outdated
Comment on lines +26 to +29
$this->addSql('DROP INDEX IDX_75EA56E016BA31DB ON messenger_messages');
$this->addSql('DROP INDEX IDX_75EA56E0FB7336F0 ON messenger_messages');
$this->addSql('DROP INDEX IDX_75EA56E0E3BD61CE ON messenger_messages');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0E3BD61CE16BA31DBBF396750 ON messenger_messages (queue_name, available_at, delivered_at, id)');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça concerne la table de Symfony/Messenger, il faudrait supprimer ces lignes, et créer une autre classe de migration juste pour ce besoin-là (qui me paraît étrange quand même)

Comment on lines +56 to +57
}
else if($booth) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else if($booth) {
} elseif ($booth) {

(ce genre de problème peut être corrigé avant de commit avec la commande make cs)

Comment thread src/Entity/Room.php Outdated
Comment on lines +141 to +170

/**
* @return Collection<int, TimeSlot>
*/
public function getTimeSlots(): Collection
{
return $this->timeSlots;
}

public function addTimeSlot(TimeSlot $timeSlot): static
{
if (!$this->timeSlots->contains($timeSlot)) {
$this->timeSlots->add($timeSlot);
$timeSlot->setRoom($this);
}

return $this;
}

public function removeTimeSlot(TimeSlot $timeSlot): static
{
if ($this->timeSlots->removeElement($timeSlot)) {
// set the owning side to null (unless already changed)
if ($timeSlot->getRoom() === $this) {
$timeSlot->setRoom(null);
}
}

return $this;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inutile ici : on n'accède pas à un TimeSlot depuis la classe Room. Y'a pas de raison de le faire, donc ce code peut être enlevé direct 👍

Comment thread src/Entity/TimeSlot.php Outdated
Comment on lines +44 to +47
#[ORM\ManyToOne(inversedBy: 'timeSlots')]
#[ORM\JoinColumn(nullable: false)]
private Room $room;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce que tu peux déplacer cette propriété juste au-dessus de la propriété $booth ?

Comment thread src/Entity/TimeSlot.php Outdated
Comment thread src/Entity/TimeSlot.php Outdated
Copy link
Copy Markdown
Member

@Pierstoval Pierstoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut également supprimer le dossier .idea du versioning

Comment thread test.bash Outdated
Comment thread src/Entity/TimeSlot.php Outdated
Comment thread src/DataFixtures/TimeSlotFixture.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants