/**
  * @param ShiftType $shiftType
  * @return ShiftTypeListDTO
  */
 public function shiftTypesToShiftTypeListDTO(ShiftType $shiftType)
 {
     $shiftTypeEmbeddedListDTO = new ShiftTypeListDTO();
     $shiftTypeEmbeddedListDTO->id = $shiftType->getId();
     $shiftTypeEmbeddedListDTO->name = $shiftType->getName();
     $shiftTypeEmbeddedListDTO->start = $this->dateTimeService->convertToLocalTimeString($shiftType->getStart());
     $shiftTypeEmbeddedListDTO->end = $this->dateTimeService->convertToLocalTimeString($shiftType->getEnd());
     return $shiftTypeEmbeddedListDTO;
 }
 private function createShiftType($name)
 {
     $shiftType = ShiftType::registerShiftType($name, new \DateTime(), new \DateTime());
     $current = $this->init->shiftTypeRepo->findOneBy(array('name' => $name));
     if (empty($current)) {
         $this->init->shiftTypeRepo->store($shiftType);
         return $shiftType;
     }
     return $current;
 }
Example #3
0
 /**
  * @param $name
  * @param $start
  * @param $end
  * @param null $memo
  * @return ShiftType
  */
 public static function registerShiftType($name, $start, $end, $memo = null)
 {
     $shiftType = new ShiftType();
     $shiftType->setName($name);
     $shiftType->setStart($start);
     $shiftType->setEnd($end);
     $shiftType->setMemo($memo);
     return $shiftType;
 }
Example #4
0
 public function testShiftCRUD()
 {
     $from = \DateTime::createFromFormat('H:i', '10:00');
     $to = \DateTime::createFromFormat('H:i', '14:00');
     $shiftType = ShiftType::registerShiftType('Test123', $from, $to);
     $this->init->shiftTypeRepo->store($shiftType);
     $this->init->em->flush();
     $find = $this->init->shiftTypeRepo->find($shiftType->getId());
     $this->assertEquals($shiftType, $find);
     $workDay = WorkingDay::registerWorkingDay(new \DateTime());
     $this->init->workingDayRepo->store($workDay);
     $shift = Shift::registerShift($workDay, $shiftType, 12);
     $this->init->shiftRepo->store($shift);
     $this->init->em->flush();
     $find = $this->init->shiftRepo->find($shift->getId());
     $this->assertEquals($shift, $find);
 }
 /**
  * @param ShiftType $match
  * @return bool
  */
 protected function matchShiftType(ShiftType $match)
 {
     foreach ($this->getShiftTypes() as $shiftType) {
         if ($shiftType->getId() == $match->getId()) {
             return true;
         }
     }
     return false;
 }