public function __construct($bookers, $base, $billId) { $this->bookers = array(); if ($base instanceof FlightBooker) { $bookerComp = new FlightBookerComponent(); $bookerComp->setFlightBookerFromId($base->id); $base = $bookerComp; } $this->base = $base; foreach ($bookers as $booker) { if ($booker instanceof FlightBooker) { $bookerComp = new FlightBookerComponent(); $bookerComp->setFlightBookerFromId($booker->id); $this->bookers[] = $bookerComp; } elseif ($booker instanceof HotelBooker) { $bookerComp = new HotelBookerComponent(); $bookerComp->setHotelBookerFromId($booker->id); $this->bookers[] = $bookerComp; } else { $this->bookers[] = $booker; } } $this->_billId = $billId; if ($billId) { $this->setBillId($billId); } }
public function actionChangeState($hotelBookerId = 0, $newState = '') { if ($hotelBookerId) { /** @var HotelBookerComponent $hotelBookerComponent */ $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBookerId); echo "HotelBookerId " . $hotelBookerComponent->getHotelBookerId() . PHP_EOL; echo "Current status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . PHP_EOL; echo "Next possible status are " . $hotelBookerComponent->getCurrent()->swGetNextStatus() . PHP_EOL; echo "Trying to change status to {$newState}" . PHP_EOL; if ($newState) { $res = $hotelBookerComponent->status($newState); if (!$res) { CVarDumper::dump($hotelBookerComponent->getCurrent()->getErrors()); CVarDumper::dump($hotelBookerComponent->getCurrent()->getAttributes()); echo PHP_EOL; } else { $hotelBookerComponent->getCurrent()->onlySave(); } echo "Status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . "\n"; } } else { $helpText = $this->getHelp(); $helpText = str_replace('command', 'ChangeState', $helpText); echo $helpText; } }
public function getBookers() { $bookerIds = $this->getBookerIds(); if (!$bookerIds) { throw new Exception("No bookers availiable"); } $bookers = array(); foreach ($bookerIds as $entry) { if ($entry['type'] == 'avia') { $flightBookerComponent = new FlightBookerComponent(); $flightBookerComponent->setFlightBookerFromId($entry['bookerId']); $bookers[] = $flightBookerComponent; } else { if ($entry['type'] == 'hotel') { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($entry['bookerId']); $bookers[] = $hotelBookerComponent; } else { throw new Exception("Unexpected segment type"); } } } return $bookers; }
public function actionTicketHotel($bookingId) { $booking = new HotelBookerComponent(); $booking->setHotelBookerFromId($bookingId); $booking->status('ticketing'); $this->redirect(array('view', 'id' => $booking->getCurrent()->orderBookingId)); }