本文整理汇总了PHP中RequestHandler::responseMode方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::responseMode方法的具体用法?PHP RequestHandler::responseMode怎么用?PHP RequestHandler::responseMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler::responseMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: respondLoginPrompt
/**
* Print login page and exit
* @return nothing
* @param object $AuthException[optional]
*/
public function respondLoginPrompt($authException = false)
{
if (Site::$pathStack[0] == 'json' || $_REQUEST['format'] == 'json' || $_SERVER['HTTP_ACCEPT'] == 'application/json') {
RequestHandler::$responseMode = 'json';
}
header('HTTP/1.1 401 Unauthorized');
$postVars = $_POST;
unset($postVars[static::$requestContainer]);
RequestHandler::respond('login/login', array('success' => false, 'loginRequired' => true, 'requestContainer' => static::$requestContainer, 'error' => $authException ? $authException->getMessage() : false, 'postVars' => $postVars));
}
示例2: array
<?php
RequestHandler::$responseMode = 'csv';
RequestHandler::respond('projects', array('data' => array_map(function ($Project) {
preg_match('/^\\s*[^*#]\\s*\\w.*/m', $Project->README, $matches);
return array('name' => $Project->Title, 'description' => trim($matches[0]), 'link_url' => $Project->UsersUrl, 'code_url' => $Project->DevelopersUrl, 'type' => '', 'categories' => implode(', ', array_map(function ($Tag) {
return $Tag->UnprefixedTitle;
}, array_filter($Project->Tags, function ($Tag) {
return $Tag->Prefix == 'topic';
}))));
}, Laddr\Project::getAll())));
示例3: EmergenceSyncer
<?php
$GLOBALS['Session']->requireAccountLevel('Developer');
set_time_limit(0);
RequestHandler::$responseMode = 'json';
if (empty($_REQUEST['path'])) {
RequestHandler::throwError('path required');
}
if (empty($_REQUEST['host'])) {
RequestHandler::throwError('host required');
}
if (!($sourceCollection = Site::resolvePath($_REQUEST['path']))) {
RequestHandler::throwError('path not found locally');
}
// create stream context for remote server
$syncer = new EmergenceSyncer(array('host' => $_REQUEST['host'], 'authUsername' => $_SERVER['PHP_AUTH_USER'], 'authPassword' => $_SERVER['PHP_AUTH_PW']));
$diff = $syncer->diffCollection($sourceCollection, !empty($_REQUEST['deep']));
if (empty($_REQUEST['push'])) {
RequestHandler::respond('diff', array('diff' => $diff));
} else {
$result = $syncer->pushDiff($diff);
RequestHandler::respond('pushComplete', array('result' => $result));
}