public function testLoadsApproveRulesFromPlugins()
 {
     $this->plugin->expects($this->once())->method('CreatePostApproveService')->with($this->fakeUser)->will($this->returnValue($this->service));
     $reservationValidationFactory = new ReservationNotificationFactory();
     $actual = $reservationValidationFactory->Create(ReservationAction::Approve, $this->fakeUser);
     $this->assertEquals($this->service, $actual);
 }
示例#2
0
 /**
  * @static
  * @param $reservationAction string|ReservationAction
  * @param $persistenceService null|IReservationPersistenceService
  * @param UserSession $session
  * @return IReservationHandler
  */
 public static function Create($reservationAction, $persistenceService, UserSession $session)
 {
     if (!isset($persistenceService)) {
         $persistenceFactory = new ReservationPersistenceFactory();
         $persistenceService = $persistenceFactory->Create($reservationAction);
     }
     $validationFactory = new ReservationValidationFactory();
     $validationService = $validationFactory->Create($reservationAction, $session);
     $notificationFactory = new ReservationNotificationFactory();
     $notificationService = $notificationFactory->Create($reservationAction, $session);
     return new ReservationHandler($persistenceService, $validationService, $notificationService);
 }
示例#3
0
文件: update.php 项目: Trideon/gigolo
}
if ($user->Id() == $series->UserId()) {
    $series->WithOwner($user->Id());
}
$title = $series->Title();
if ($params['summary']) {
    $title = $params['summary'];
}
$description = $series->Description();
if ($params['description']) {
    $description = $params['description'];
}
$series->Update($user->Id(), $resource, $title, $description, $user_session);
$vfactory = new ReservationValidationFactory();
$validationService = $vfactory->Create($updateAction, $user_session);
$nfactory = new ReservationNotificationFactory();
$notificationService = $nfactory->Create($updateAction, $user_session);
$validationResult = $validationService->Validate($series);
$result = $validationResult->CanBeSaved();
if ($result) {
    try {
        $persistenceService->Persist($series);
        header('HTTP/1.1 200 Ok', true, 200);
        $rn = $series->CurrentInstance()->ReferenceNumber();
        $response = array('series_id' => $series->SeriesId(), 'title' => $title, 'description' => $description, 'reference_number' => $rn);
        //print json_encode($response,JSON_UNESCAPED_SLASHES);  ## only in Php 5.4
        print json_encode($response);
        return;
    } catch (Exception $ex) {
        Log::Error('Error updating reservation: %s', $ex);
        throw $ex;
示例#4
0
文件: create.php 项目: Trideon/gigolo
    return;
}
/*************************************************
 	date
 *************************************************/
$timing = DateRange::Create($starts_at, $ends_at, $tz);
/*************************************************
 	Action
 *************************************************/
$series = ReservationSeries::Create($user->Id(), $resource, $title, $description, $timing, new RepeatNone(), $user_session);
$reservationAction = ReservationAction::Create;
$pfactory = new ReservationPersistenceFactory();
$persistenceService = $pfactory->Create($reservationAction);
$vfactory = new ReservationValidationFactory();
$validationService = $vfactory->Create($reservationAction, $user_session);
$nfactory = new ReservationNotificationFactory();
$notificationService = $nfactory->Create($reservationAction, $user_session);
#	$handler = new ReservationHandler($persistenceService, $validationService, $notificationService);
$validationResult = $validationService->Validate($series);
$result = $validationResult->CanBeSaved();
if ($result) {
    try {
        $persistenceResult = $persistenceService->Persist($series);
        header('HTTP/1.1 200 Ok', true, 200);
        $response = array('series_id' => $series->SeriesId(), 'reference_number' => $series->CurrentInstance()->ReferenceNumber(), 'requires_approval' => $resource->GetRequiresApproval());
        print json_encode($response);
        return;
    } catch (Exception $ex) {
        //Log::Error('Error saving reservation: %s', $ex);
        header('HTTP/1.1 403 Forbidden', true, 403);
        print json_encode(array('message' => "exception in making reservation persistant"));