public function getFreeWorkTimes(User $user, \DateTime $date = null)
 {
     $allTimes = [];
     //if($date)
     //{
     $startTime = new \DateTime($date->format('Y-m-d H:i'));
     $endTime = new \DateTime($date->format('Y-m-d H:i'));
     $startTime->setTime($user->getStartTime()->format('H'), $user->getStartTime()->format('i'));
     $endTime->setTime($user->getEndTime()->format('H'), $user->getEndTime()->format('i'));
     //}else
     //{
     //    $startTime = new \DateTime($user->getStartTime()->format('H:i'));
     //    $endTime = new \DateTime($user->getEndTime()->format('H:i'));
     //}
     $busyTimes = $this->em->getRepository('WorkerBundle:WorkTime')->getUserBusyTimes($user->getId());
     while ($startTime < $endTime) {
         if ($startTime > new \DateTime()) {
             //    if ($date) {
             $allTimes[] = $startTime->format('Y-m-d H:i');
             //    } else {
             //          $allTimes[] = date('Y-m-d') . ' ' . $startTime->format('H:i');
             //   }
         }
         $startTime->modify('+1hour');
     }
     return $this->removeBlockedTimes($allTimes, $busyTimes);
 }
 /**
  * {@inheritDoc}
  */
 public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) parent::getId();
     }
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);
     return parent::getId();
 }