本文整理汇总了PHP中bootstrap::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP bootstrap::getInstance方法的具体用法?PHP bootstrap::getInstance怎么用?PHP bootstrap::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bootstrap
的用法示例。
在下文中一共展示了bootstrap::getInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assignAction
function assignAction()
{
$user = \bootstrap::getInstance()->getUser();
if (!$user['id'] || $user['type'] != 'admin') {
return $this->_redirect('/');
}
$staff_id = $this->params('staff');
$staff = $this->userDataMapper()->find(array('id' => $staff_id));
$form = $this->servicesForm();
if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
$this->userDataMapper()->unassignServices($staff_id);
$this->userDataMapper()->assignMultiple($form->getValue('services'), $staff_id);
$this->flashMessenger()->addMessage('Staff\'s Services Updated');
if (isset($_SESSION['admin_setup'])) {
return $this->redirect()->toRoute('staff-availability', ['staff' => $user['id']]);
}
return $this->redirect()->toRoute('manage-staff');
}
$this->viewParams['staff'] = $staff;
$this->viewParams['form'] = $form;
if (isset($_SESSION['admin_setup'])) {
$this->viewParams['admin_setup'] = 1;
}
return $this->viewParams;
}
示例2: indexAction
function indexAction()
{
$this->init();
$layoutViewModel = $this->layout();
$progress = new ViewModel(['step' => 2]);
$progress->setTemplate('application/progress');
$layoutViewModel->addChild($progress, 'progress');
$user = \bootstrap::getInstance()->getUser();
$staffSelector = $this->staffSelector(true, $this->params('service'));
if (!is_null($staffSelector->getValue('staff'))) {
$this->staff_selection = $staffSelector->getValue('staff');
} else {
$this->staff_selection = $this->listStaff($this->params()->fromQuery('service'));
}
$this->viewParams = $this->viewParams + ['staffSelector' => $staffSelector, 'therapist_id' => $this->params()->fromQuery('staff'), 'service' => $this->params('service')];
$this->renderCalendar($this->viewParams);
/** Display controls to toggle between week & calendar views */
$this->viewParams['mode'] = $this->params('mode');
$viewModel = new ViewModel($this->viewParams);
$viewModel->setTemplate('application/calendar-mode-chooser');
//return $viewModel;
$viewModel = new ViewModel($this->viewParams);
if ($this->params('mode') == 'week') {
/** Display the week view */
$viewModel->setTemplate('week-choose');
} else {
/** Display the calendar */
$viewModel->setTemplate('application/calendar-choose');
}
return $viewModel;
}
示例3: init
function init()
{
$user = \bootstrap::getInstance()->getUser();
if ($this->requestedCalendarOutOfRange()) {
$this->viewParams['limitMonths'] = $this->limitMonths;
$viewModel->setTemplate('limited', null, true);
$month = date('m');
$year = date('Y');
} else {
$month = $this->month();
$year = $this->year();
}
$this->number_of_days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$this->viewParams['year'] = $year;
$this->viewParams['month'] = $month;
$this->viewParams['month_name'] = date('F', strtotime('1-' . $month . '-' . $year));
$this->viewParams['number_of_days_in_month'] = $this->number_of_days_in_month;
}
示例4: cancelAction
function cancelAction()
{
$user = \bootstrap::getInstance()->getUser();
if (!$user['id']) {
return $this->_redirect('/');
}
$db = \Zend_Registry::get('db');
$newValues = array('canceled' => 1);
$condition = 'id=' . (int) $this->params('id');
$appointment_date = $db->select()->from('appointments', array('date'))->where('id=?', $this->params('id'))->query()->fetchColumn();
if ($user['type'] == 'client') {
$booking = new Booking(array('today' => date('Y-m-d'), 'date' => $appointment_date));
if (!$booking->allowCancelByUser()) {
echo 'not allowed to cancel';
exit;
}
$condition .= ' && user_id = ' . (int) $user['id'];
} else {
if ($user['type'] == 'staff') {
$condition .= ' && staff_userid = ' . (int) $user['id'];
} else {
if ($user['type'] !== 'admin') {
return $this->_redirect('/');
}
}
}
$db->update('appointments', $newValues, $condition);
$logMessage = 'Therapist appointment #' . (int) $this->params('id');
$logMessage .= ' cancelled by user #' . $user['id'];
$this->cancelsLogger()->log($logMessage, Zend_Log::INFO);
$this->viewParams['date'] = $appointment_date;
$viewModel = new ViewModel($this->viewParams);
$viewModel->setTemplate('appointments/cancel.phtml');
$htmlOutput = $this->getServiceLocator()->get('viewrenderer')->render($viewModel);
$mail = new Zend_Mail();
$mail->addTo($user['email']);
$mail->setBodyText($htmlOutput);
$this->queueMail($mail);
echo $htmlOutput;
$this->_helper->viewRenderer->setNoRender(true);
}
示例5: indexAction
function indexAction()
{
$user = \bootstrap::getInstance()->getUser();
if (!$user['id'] || $user['type'] != 'staff' && $user['type'] != 'admin') {
return $this->_redirect('/');
}
if ($user['type'] == 'admin' && !$this->params('staff')) {
throw new Exception('Admin must have a staff selected');
}
$this->viewParams['availability'] = array();
for ($day = 1; $day <= 7; $day++) {
$staff = $user['type'] == 'admin' ? $this->params('staff') : $user['id'];
$this->viewParams['availability'][$day] = $this->selectAvailability($day, null, $staff);
}
$db = \Zend_Registry::get('db');
if ($this->params()->fromQuery('remove')) {
$db->delete('availability', array('id = ' . (int) $this->params()->fromQuery('remove')));
$this->flashMessenger()->addMessage('Deleted Availability');
return $this->redirect()->toUrl($this->url()->fromRoute('staff-availability', array(), true));
}
$form = new \Application\AvailabilityForm();
if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
$staff_userid = $user['type'] == 'admin' ? $this->params('staff') : $user['id'];
$parameters = array('staff_userid' => $staff_userid, 'day_of_week' => $form->getValue('day'), 'start' => $form->getValue('start'), 'end' => $form->getValue('end'));
$this->availabilityDataMapper()->insert($parameters);
$this->flashMessenger()->addMessage('Added Availability');
if (isset($_SESSION['admin_setup'])) {
return $this->redirect()->toRoute('home');
}
return $this->redirect()->toUrl($this->url()->fromRoute('staff-availability', array(), true));
}
$this->viewParams['form'] = $form;
if (isset($_SESSION['admin_setup'])) {
$this->viewParams['admin_setup'] = 1;
}
$viewModel = new ViewModel($this->viewParams);
$viewModel->setTemplate('application/availability-manage.phtml');
return $viewModel;
}
示例6: preDispatch
function preDispatch()
{
$user = \bootstrap::getInstance()->getUser();
}
示例7: Exception
// If being run from sub-domain, load the hosted client's config
$id = $matches[1];
$file = '../website/var/website_configs/' . $id;
if (!file_exists($file)) {
throw new Exception('Unkown client');
}
define('APPLICATION_ENVIRONMENT', 'production');
} else {
// If being run on localhost
define('APPLICATION_ENVIRONMENT', 'localhost');
$file = 'database-config.ini';
}
if (!file_exists($file)) {
$file = 'database-config.ini.dist';
}
$config = new Zend_Config_Ini($file, APPLICATION_ENVIRONMENT);
Zend_Registry::set('database_config', $config);
Zend_Registry::set('mysql_command', $config->mysql_command);
}
function startDb()
{
$configuration = Zend_Registry::get('database_config');
Zend_Registry::set('db', new Zend_Db_Adapter_Pdo_Mysql($configuration->database->params));
}
function getRequest()
{
return $this->frontController->getRequest();
}
}
$bootstrap = bootstrap::getInstance();
$bootstrap->execute();
示例8:
<?php
use lib\url;
$conf = \bootstrap::getInstance('conf');
?>
<footer>
<p>© myAppOne 2014</p>
</footer>
示例9: admintutorialAction
function admintutorialAction()
{
$user = \bootstrap::getInstance()->getUser();
if ($user['type'] == 'admin') {
$_SESSION['admin_setup'] = 1;
return $this->redirect()->toRoute('new-service');
}
}