コード例 #1
0
 /**
  * @param string  $officeAlias
  * @param integer $day
  * @param integer $hour
  *
  * @return Appointment
  */
 public function create($officeAlias, $day, $hour)
 {
     if ($hour < 10) {
         $hour = '0' . $hour;
     }
     /** @var Client $client */
     $client = $this->getReference('client:00');
     /** @var Office $office */
     $office = $this->getReference($officeAlias);
     $serviceAlias = $this->services[rand(0, 5)];
     $description = 'Description: ' . $serviceAlias;
     /** @var Service $service */
     $service = $this->getReference('service:' . $serviceAlias);
     $date = new \DateTime($day . ' day');
     $date = new \DateTime($date->format('Y-m-d') . ' ' . $hour . ":00:00");
     if ($date->format('w') == 0 && $hour >= 13) {
         return;
     }
     $appointment = new Appointment();
     $appointment->setClient($client);
     $appointment->setDateTime($date);
     $appointment->setOffice($office);
     $appointment->setDuration(30);
     $appointment->setDescription($description);
     $appointment->setService($service);
     $appointment->setUser($this->getReference($this->doctors[rand(0, 4)]));
     return $appointment;
 }
コード例 #2
0
 /**
  * @param ParameterBag $params
  *
  * @return Appointment
  */
 public function create($params)
 {
     $entity = new Appointment();
     $entity->setClient($params->get('client'));
     $entity->setDateTime($params->get('dateTime'));
     $entity->setDuration($params->get('duration'));
     $entity->setOffice($params->get('office'));
     $entity->setDescription($params->get('description'));
     $entity->setService($params->get('service'));
     $entity->setState($params->get('state', Appointment::STATE_NEW));
     $entity->setUser($params->get('user'));
     $this->persist($entity);
     return $entity;
 }