Beispiel #1
0
 /**
  * Set free status
  *
  * @param \Entity\Device $entity
  * @return Response
  */
 public function free($entity)
 {
     if (!$entity->getUser() && $entity->getLocation()->getId() != $this->getUser()->getLocation()->getId()) {
         throw new YouAreNotOwnerException();
     }
     if ($entity->getState()->getId() != 2) {
         throw new OrderNotBusyException();
     }
     $entity->setState($this->cast('Mapper\\DeviceState', 1));
     $this->flush();
     $response = new Response();
     $response->redirect('/device/location');
     return $response;
 }