/** * action createParticipant * * @param Reservation $reservation * @param Person $newParticipant * @return void */ public function createParticipantAction(Reservation $reservation, Person $newParticipant) { if (!$reservation->getStatus() == Reservation::STATUS_DRAFT) { $reservation->setStatus(Reservation::STATUS_DRAFT); } if ($reservation->getLesson()->getFreePlaces()) { $newParticipant->setReservation($reservation); $newParticipant->setType(Person::PERSON_TYPE_PARTICIPANT); $reservation->addParticipant($newParticipant); $reservation->getLesson()->addParticipant($newParticipant); $this->reservationRepository->update($reservation); $this->lessonRepository->update($reservation->getLesson()); $this->persistenceManager->persistAll(); $this->addFlashMessage($this->translate('message.reservation.createParticipant.success')); } $this->redirect('edit', null, null, ['reservation' => $reservation]); }
/** * Returns an array of constraints created from a given demand object. * * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query * @param \DWenzel\T3events\Domain\Model\Dto\DemandInterface $demand * @return array<\TYPO3\CMS\Extbase\Persistence\Generic\Qom\Constraint> */ protected function createConstraintsFromDemand(QueryInterface $query, DemandInterface $demand) { $constraints = parent::createConstraintsFromDemand($query, $demand); /** @var ScheduleDemand $demand */ if ($demand->getDeadlineBefore() !== NULL) { $constraints[] = $query->lessThanOrEqual('deadline', $demand->getDeadlineBefore()); } if ($demand->getDeadlineAfter() !== NULL) { $constraints[] = $query->greaterThan('deadline', $demand->getDeadlineAfter()); } $constraintsConjunction = $demand->getConstraintsConjunction(); if ($demand->getGenres()) { $genres = GeneralUtility::intExplode(',', $demand->getGenres()); $genreConstraints = []; foreach ($genres as $genre) { $genreConstraints[] = $query->contains('course.genre', $genre); } $this->combineConstraints($query, $constraints, $genreConstraints, $constraintsConjunction); } if ($demand->getEventLocations()) { $eventLocations = GeneralUtility::intExplode(',', $demand->getEventLocations()); $eventLocationConstraints = []; foreach ($eventLocations as $eventLocation) { $eventLocationConstraints[] = $query->equals('eventLocation.uid', $eventLocation); } $this->combineConstraints($query, $constraints, $eventLocationConstraints, $constraintsConjunction); } if ($demand->getEventTypes()) { $eventTypes = GeneralUtility::intExplode(',', $demand->getEventTypes()); $eventTypeConstraints = []; foreach ($eventTypes as $eventType) { $eventTypeConstraints[] = $query->equals('course.eventType.uid', $eventType); } $this->combineConstraints($query, $constraints, $eventTypeConstraints, $constraintsConjunction); } if ($demand->getAudiences()) { $audiences = GeneralUtility::intExplode(',', $demand->getAudiences()); $audienceConstraints = []; foreach ($audiences as $audience) { $audienceConstraints[] = $query->equals('course.audience.uid', $audience); } $this->combineConstraints($query, $constraints, $audienceConstraints, $constraintsConjunction); } return $constraints; }