/**
  * @param Model $model
  *
  * @return JobCalendar
  */
 public function modelToEntity(Model $model)
 {
     // Load entity if id, else init new object
     $jobCalendar = new JobCalendar();
     if (null !== $model->getId()) {
         $jobCalendar = $this->manager->getRepository('AppBundle:JobCalendar')->find($model->getId());
     }
     // Load dependencies
     if (null !== $model->getJob() && null !== $model->getJob()->getId()) {
         $job = $this->manager->getRepository('AppBundle:Job')->find($model->getJob()->getId());
         if (null !== $job) {
             $jobCalendar->setJob($job);
         }
     }
     if (null !== $model->getCalendar() && null !== $model->getCalendar()->getId()) {
         $calendar = $this->manager->getRepository('AppBundle:Calendar')->find($model->getCalendar()->getId());
         if (null !== $calendar) {
             $jobCalendar->setCalendar($calendar);
         }
     }
     // Set others attributes
     return $jobCalendar->setDate($model->getDate());
 }
 /**
  * @param GoogleConnection $connection
  * @param JobCalendar      $model
  *
  * @return GoogleLink
  */
 private function getGoogleLink(GoogleConnection $connection, JobCalendar $model)
 {
     return $this->manager->getRepository('AppBundle:GoogleLink')->findOneBy(['connectionId' => $connection->getId(), 'type' => Calendar::EVENT_TYPE_JOB, 'calendarId' => $model->getCalendar()->getId(), 'internalId' => $model->getId()]);
 }