本文整理汇总了PHP中CommandContext::Get方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandContext::Get方法的具体用法?PHP CommandContext::Get怎么用?PHP CommandContext::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandContext
的用法示例。
在下文中一共展示了CommandContext::Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandContext $context)
{
if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'bed_structure')) {
PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
throw new PermissionException('You do not have permission to add a bed.');
}
PHPWS_Core::initModClass('hms', 'HMS_Room.php');
PHPWS_Core::initModClass('hms', 'HMS_Bed.php');
$errorCmd = CommandFactory::getCommand('ShowAddBed');
$errorCmd->setRoomId($context->get('roomId'));
$errorCmd->setBedLetter($context->get('bed_letter'));
$errorCmd->setBedroomLabel($context->get('bedroom_label'));
$errorCmd->setBannerId($context->get('banner_id'));
$viewCmd = CommandFactory::getCommand('EditRoomView');
$viewCmd->setRoomId($context->get('roomId'));
$bedLetter = $context->get('bed_letter');
$bedroomLabel = $context->get('bedroom_label');
$bannerId = $context->get('banner_id');
$roomId = $context->get('roomId');
$phoneNumber = $context->get('phone_number');
if (!isset($bedLetter)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'You must enter a bed letter.');
$errorCmd->redirect();
}
if (!isset($bedroomLabel)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'You must enter a bedroom label.');
$errorCmd->redirect();
}
if (!isset($bannerId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'You must enter a banner ID.');
$errorCmd->redirect();
}
if (!isset($roomId)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Missing room ID.');
$errorCmd->redirect();
}
$raBed = $context->Get('ra') == 1 ? 1 : 0;
$raRoommate = $context->get('ra_roommate') == 1 ? 1 : 0;
$intlReserved = $context->get('international_reserved') == 1 ? 1 : 0;
$room = new HMS_Room($roomId);
if (is_null($room)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'Could not create bed. Invalid room.');
$errorCmd->redirect();
}
$term = $room->term;
$persistentId = uniqid();
# Try to create the bed
try {
HMS_Bed::addBed($roomId, $term, $bedLetter, $bedroomLabel, $phoneNumber, $bannerId, $raRoommate, $intlReserved, $raBed, $persistentId);
} catch (Exception $e) {
NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error creating the bed: ' . $e->getMessage());
$errorCmd->redirect();
}
NQ::simple('hms', hms\NotificationView::SUCCESS, 'Bed added successfully.');
$viewCmd->redirect();
}
示例2: execute
public function execute(CommandContext $context)
{
// Load the checkin object
$checkinId = $context->Get('checkinId');
$checkin = CheckinFactory::getCheckinById($checkinId);
if (!isset($checkin) || is_null($checkin)) {
NQ::simple('hms', hms\NotificationView::ERROR, 'There was an error while looking up this checkin. Please contact ESS.');
$errCmd = CommandFactory::getCommand('ShowAdminMainMenu');
$errCmd->redirect();
}
PHPWS_Core::initModClass('hms', 'CheckoutDocumentView.php');
$view = new CheckoutDocumentView($checkin);
$context->setContent($view->show());
}