Skip to content

Commit

Permalink
Task 266725
Browse files Browse the repository at this point in the history
- ApiController: eventService injected
- Refactoring changed event to event_participation in Participant, EventParticipation & Dependencies
- changed Maria DB version
  • Loading branch information
IrisOlfermann committed Jan 14, 2025
1 parent c09c68f commit fbc99de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ additional_fqdns:
- meals.test
database:
type: mariadb
version: "10.2"
version: "10.11"
performance_mode: none
hooks:
post-start:
Expand Down
2 changes: 1 addition & 1 deletion src/Mealz/MealBundle/Entity/EventParticipation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EventParticipation
#[ORM\JoinColumn(name: 'event', referencedColumnName: 'id')]
public Event $event;

#[ORM\OneToMany(mappedBy: 'event', targetEntity: Participant::class, cascade: ['persist', 'remove'])]
#[ORM\OneToMany(mappedBy: 'event_participation', targetEntity: Participant::class, cascade: ['persist', 'remove'])]
public ?Collection $participants = null;

public function __construct(Day $day, Event $event, ?Collection $participants = null)
Expand Down
6 changes: 3 additions & 3 deletions src/Mealz/MealBundle/Entity/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ public function getId(): ?int
return $this->id;
}

public function getEvent(): ?EventParticipation
public function getEventParticipation(): ?EventParticipation
{
return $this->event_participation;
}

public function setEvent(EventParticipation $event): void
public function setEventParticipation(EventParticipation $event_participation): void
{
$this->event_participation = $event;
$this->event_participation = $event_participation;
}

public function setMeal(Meal $meal): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private function participantExists(Participant $participant, EntityManager $enti

if (null !== $participant->getMeal()) {
$query = $this->buildQueryMealParticipantExists($participant, $queryBuilder);
} elseif (null !== $participant->getEvent()) {
} elseif (null !== $participant->getEventParticipation()) {
$query = $this->buildQueryEventParticipantExists($participant, $queryBuilder);
} else {
return false;
Expand Down Expand Up @@ -84,17 +84,17 @@ private function buildQueryEventParticipantExists(Participant $participant, Quer
$queryBuilder
->select('COUNT(p.id)')
->from(Participant::class, 'p')
->join('p.event', 'e')
->join('p.event_participation', 'e')
->join('p.profile', 'u')
->where('e = :event AND u = :profile')
->where('e = :event_participation AND u = :profile')
;
if ($participant->getId()) {
$queryBuilder->andWhere('p.id != :id');
$queryBuilder->setParameter('id', $participant->getId());
}

$query = $queryBuilder->getQuery();
$query->setParameter('event', $participant->getEvent()->getId());
$query->setParameter('event_participation', $participant->getEventParticipation()->getId());
$query->setParameter('profile', $participant->getProfile()->getUsername());
$query->disableResultCache();

Expand Down

0 comments on commit fbc99de

Please sign in to comment.