本文整理匯總了PHP中context::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP context::getInstance方法的具體用法?PHP context::getInstance怎麽用?PHP context::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類context
的用法示例。
在下文中一共展示了context::getInstance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: defaultData
/**
* Retrieve the data from the url and make the base initialization
*
* @return void
*/
protected function defaultData()
{
$context = Context::getInstance();
$this->setData('extension', context::getInstance()->getExtensionName());
$this->setData('module', $context->getModuleName());
$this->setData('action', $context->getActionName());
if ($this->hasRequestParameter('uri')) {
// @todo stop using session to manage uri/classUri
$this->setSessionAttribute('uri', $this->getRequestParameter('uri'));
// inform the client of new classUri
$this->setData('uri', $this->getRequestParameter('uri'));
}
if ($this->hasRequestParameter('classUri')) {
// @todo stop using session to manage uri/classUri
$this->setSessionAttribute('classUri', $this->getRequestParameter('classUri'));
if (!$this->hasRequestParameter('uri')) {
$this->removeSessionAttribute('uri');
}
// inform the client of new classUri
$this->setData('uri', $this->getRequestParameter('classUri'));
}
if ($this->getRequestParameter('message')) {
$this->setData('message', $this->getRequestParameter('message'));
}
if ($this->getRequestParameter('errorMessage')) {
$this->setData('errorMessage', $this->getRequestParameter('errorMessage'));
}
$this->setData('client_timeout', $this->getClientTimeout());
$this->setData('client_config_url', $this->getClientConfigUrl());
}
示例2: session_start
<?php
//nom de l'application
$nameApp = "ApiTest";
//action par défaut
$action = "index";
if (key_exists("action", $_REQUEST)) {
$action = $_REQUEST['action'];
}
require_once 'lib/core.php';
require_once $nameApp . '/controller/mainController.php';
session_start();
$context = context::getInstance();
$context->init($nameApp);
$json = $context->executeAction($action, $_REQUEST);
//traitement des erreurs de bases, reste à traiter les erreurs d'inclusion
if ($json === false) {
echo "Une grave erreur s'est produite, il est probable que l'action " . $action . " n'existe pas...";
die;
} else {
if ($json != context::NONE) {
echo $json;
}
}