本文整理汇总了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;
}
}