Skip to content

Commit

Permalink
added seperate methods for event and meal invitation
Browse files Browse the repository at this point in the history
  • Loading branch information
IrisOlfermann committed Sep 6, 2024
1 parent 73cb280 commit 653bc6b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
32 changes: 25 additions & 7 deletions src/Mealz/MealBundle/Repository/GuestInvitationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,41 @@
class GuestInvitationRepository extends BaseRepository implements GuestInvitationRepositoryInterface
{
/**
* Gets the event guest invitation from a particular user on a particular day.
*
* @throws ORMException
* @throws OptimisticLockException
*/
public function findOrCreateEventInvitation(Profile $host, Day $day, ?EventParticipation $eventParticipation): GuestInvitation
{
$entityManager = $this->getEntityManager();
if($eventParticipation){
$invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId(), 'eventParticipation' => $eventParticipation]);
}


if (($invitation instanceof GuestInvitation) === false) {
$invitation = new GuestInvitation($host, $day,$eventParticipation);
$entityManager->persist($invitation);
$entityManager->flush();
}

return $invitation;
}

/**
* Gets the guest invitation from a particular user on a particular day.
*
* @throws ORMException
* @throws OptimisticLockException
*/
public function findOrCreateInvitation(Profile $host, Day $day, ?EventParticipation $eventParticipation): GuestInvitation
public function findOrCreateInvitation(Profile $host, Day $day): GuestInvitation
{
$entityManager = $this->getEntityManager();
$eventParticipation?
$invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId(), 'eventParticipation' => $eventParticipation->getId()])
:
$invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId()]);
$entityManager->persist($eventParticipation);
$entityManager->persist($day);

if (($invitation instanceof GuestInvitation) === false) {
$invitation = new GuestInvitation($host, $day,$eventParticipation);
$invitation = new GuestInvitation($host, $day);
$entityManager->persist($invitation);
$entityManager->flush();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ interface GuestInvitationRepositoryInterface extends ObjectRepository
/**
* Gets the guest invitation from a particular user on a particular day.
*/
public function findOrCreateInvitation(Profile $host, Day $day, EventParticipation $eventParticipation): GuestInvitation;
public function findOrCreateEventInvitation(Profile $host, Day $day, ?EventParticipation $eventParticipation): GuestInvitation;
/**
* Gets the guest invitation from a particular user on a particular day.
*/
public function findOrCreateInvitation(Profile $host, Day $day): GuestInvitation;
}

0 comments on commit 653bc6b

Please sign in to comment.