public function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } if (is_null($values['date'])) { $valid = true; } else { $roomprofileId = $values['RoomProfile_id']; $roomprofile = RoomprofilePeer::retrieveByPk($roomprofileId); if (is_null($roomprofile)) { $valid = true; } else { $roomId = $roomprofile->getRoomId(); $valid = !ReservationPeer::overlaps($values['id'], $values['date'], date('Y-m-d H:i:s', strtotime($values['date'] . ' +' . $values['duration'] . ' minute')), $roomId); } } if (!$valid) { $error = new sfValidatorError($this, 'invalid', array()); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('date' => $error)); } return $values; }
public function executeDelete(sfWebRequest $request) { $request->checkCSRFProtection(); $this->forward404Unless($roomprofile = RoomprofilePeer::retrieveByPk($request->getParameter('id')), sprintf('Object roomprofile does not exist (%s).', $request->getParameter('id'))); $roomId = $roomprofile->getRoomId(); $roomprofile->delete(); $this->redirect('roomprofile/index?roomId=' . $roomId); }