/** ------------------------- * Create a driving assertion, assign driver and shift. * * @param Driver $driver * @param $swissDate * @param $shiftTypeName * @return bool */ private function registerUniqueDrivingAssertion(Driver $driver, $swissDate, $shiftTypeName) { /** @var DateTimeService $dateTimeService */ $dateTimeService = $this->container->get('tixi_api.datetimeservice'); $dt = $dateTimeService->convertDateTimeStringToUTCDateTime($swissDate . ' 00:00'); /** @var ShiftRepository $shiftRepository */ $shiftRepository = $this->container->get('shift_repository'); $shifts = $shiftRepository->findShiftsForDay($dt); /** @var Shift $shift */ foreach ($shifts as $shift) { if ($shift->getShiftType()->getName() == $shiftTypeName) { if (!$driver->hasDrivingAssertionForShift($shift)) { $drivingAssertion = DrivingAssertion::registerDrivingAssertion($driver, $shift); /** @var DrivingAssertionRepository $daRepository */ $daRepository = $this->container->get('drivingassertion_repository'); $daRepository->store($drivingAssertion); return true; /* success */ } } } return false; /* failure */ }