public function updateEvent(Event $event, Reservation $reservation)
 {
     $event->setStart($reservation->getStartInTimestamp());
     $event->setEnd($reservation->getEndInTimestamp());
     $event->setTitle($this->translator->trans('reservation', [], 'reservation') . ' - ' . $reservation->getResource()->getName());
     $event->setIsEditable(false);
     return $event;
 }
 /**
  * Imports ical files.
  *
  * @param UploadedFile $file
  * @param Workspace    $workspace
  *
  * @return int number of events saved
  */
 public function importEvents(UploadedFile $file, $workspace = null)
 {
     $ical = new ICal($file->getPathname());
     $events = $ical->events();
     $tabs = [];
     foreach ($events as $event) {
         $e = new Event();
         $e->setTitle($event->summary);
         $e->setStart($ical->iCalDateToUnixTimestamp($event->dtstart));
         $e->setEnd($ical->iCalDateToUnixTimestamp($event->dtend));
         $e->setDescription($event->description);
         if ($workspace) {
             $e->setWorkspace($workspace);
         }
         $e->setUser($this->tokenStorage->getToken()->getUser());
         $e->setPriority('#01A9DB');
         $this->om->persist($e);
         //the flush is required to generate an id
         $this->om->flush();
         $tabs[] = $e->jsonSerialize();
     }
     return $tabs;
 }
 private function createAgendaEventDrop(DateTime $startDate, DateTime $endDate, $user, Dropzone $dropzone, $type = "drop")
 {
     /*
     $dateTS = new DateTime();
     $dateTS = $startDate;
     echo "TS : " . $dateTS;
     echo "TS = " . $dateTS->getTimestamp();
     */
     $event = new Event();
     $event->setStart($startDate);
     $event->setEnd($endDate);
     $event->setUser($user);
     $dropzoneName = $dropzone->getResourceNode()->getName();
     if ($type == 'drop') {
         $title = $this->get('translator')->trans('Deposit phase of the %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel');
         $desc = $this->get('translator')->trans('Evaluation %dropzonename% opening', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel');
         $event->setTitle($title);
         $event->setDescription($desc);
     } else {
         $title = $this->get('translator')->trans('Peer Review is starting in %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel');
         $desc = $this->get('translator')->trans('Peer Review is starting in %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel');
         $event->setTitle($title);
         $event->setDescription($desc);
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($event);
     $em->flush();
     return $event;
 }
 private function createAgendaEventDrop($startDate, $endDate, $user, Dropzone $dropzone, $type = 'drop')
 {
     $event = new Event();
     $event->setStart($startDate->getTimeStamp());
     $event->setEnd($endDate->getTimeStamp());
     $event->setUser($user);
     $dropzoneName = $dropzone->getResourceNode()->getName();
     if ($type == 'drop') {
         $title = $this->get('translator')->trans('Deposit phase of the %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'icap_dropzone');
         $desc = $this->get('translator')->trans('Evaluation %dropzonename% opening', array('%dropzonename%' => $dropzoneName), 'icap_dropzone');
         $event->setTitle($title);
         $event->setDescription($desc);
     } else {
         $title = $this->get('translator')->trans('Peer Review is starting in %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'icap_dropzone');
         $desc = $this->get('translator')->trans('Peer Review is starting in %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'icap_dropzone');
         $event->setTitle($title);
         $event->setDescription($desc);
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($event);
     $em->flush();
     return $event;
 }
 private function createAgendaEventDrop(User $user, Dropzone $dropzone)
 {
     $translator = $this->container->get('translator');
     $em = $this->container->get('doctrine')->getEntityManager();
     $event = new Event();
     $event->setStart($dropzone->getStartAllowDrop());
     $event->setEnd($dropzone->getEndAllowDrop());
     $event->setUser($user);
     $dropzoneName = $dropzone->getResourceNode()->getName();
     $title = $translator->trans('Deposit phase of the %dropzonename% evaluation', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel');
     $desc = $translator->trans('Evaluation %dropzonename% opening', array('%dropzonename%' => $dropzoneName), 'innova_collecticiel');
     $event->setTitle($title);
     $event->setDescription($desc);
     $em->persist($event);
     $em->flush();
     return $event;
 }