本文整理汇总了PHP中Response::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::send方法的具体用法?PHP Response::send怎么用?PHP Response::send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionIndex()
{
//echo CJSON::encode("ok");
//Yii::app()->end();
if (isset($_POST['Company'])) {
$id = (int) $_POST['Company'];
//
//if has access
//$database= Company::model()->findByPk($id);
Yii::log($id, 'info', 'app');
//Yii::app()->user->setState('Database',$database );
//Yii::app()->user->setState('Company',$id);
//echo 'ok';
Company::model()->select($id);
//redirect
Response::send();
}
if (Yii::app()->user->Company != 0) {
Yii::app()->user->setState('Company', 0);
$this->redirect('company');
Yii::app()->end();
}
$model = new Company('search');
$model->unsetAttributes();
// clear any default values
$this->render('index', array('model' => $model));
}
示例2: preview_page
public function preview_page()
{
$page = Page::getByID(intval($_REQUEST['cID'], 10), 'RECENT');
if (!is_object($page) || $page->isError()) {
throw new \InvalidArgumentException('Invalid collection ID');
}
$permissions = new Permissions($page);
if ($permissions->canPreviewPageAsUser() && $permissions->canRead() && Config::get('concrete.permissions.model') == 'advanced') {
/** @var Request $request */
$request = Request::getInstance();
$request->setCustomRequestUser(false);
$request->setCurrentPage($page);
if ($request->request('customUser')) {
$user_info = UserInfo::getByUserName($request->request('customUser'));
if ($user_info && is_object($user_info) && !$user_info->isError()) {
$request->setCustomRequestUser($user_info);
}
}
$request->setCustomRequestDateTime(Core::make('helper/form/date_time')->translate('preview_as_user_datetime', $request->request()));
$controller = $page->getPageController();
$view = $controller->getViewObject();
$response = new \Response();
$response->setContent($view->render());
$response->send();
}
}
示例3: run
public function run()
{
$route = $this->router->match($this->request);
if ($route === false) {
$actionName = self::ACTION_NOT_FOUND;
} else {
$actionName = $route->getName();
}
if (!$this->actions->has($actionName)) {
throw new \Exception(sprintf('Action %s not found', $actionName));
}
$this->store->setFileName($actionName);
if ($this->request->isAjax()) {
$this->view->setRenderType(View::RENDER_JSON);
} else {
$this->view->setContentView('error');
}
$action = $this->actions->get($actionName);
call_user_func_array($action, array($this));
if (is_callable($this->postAction)) {
call_user_func_array($this->postAction, array($this));
}
$this->response->setContent($this->view->render());
$this->response->send();
}
示例4: to
public static function to($url)
{
Response::clean();
Response::header('Location', $url);
Response::send();
exit;
}
示例5: handle
/**
* When this type of exception isn't caught this method is called by
* Error::exception_handler() to deal with the problem.
*/
public function handle()
{
$response = new \Response(\View::forge('404'), 404);
\Event::shutdown();
$response->send(true);
return;
}
示例6: preview
public function preview()
{
$request = \Request::getInstance();
$c = \Page::getByID($this->request->get('cID'));
$cp = new \Permissions($c);
if ($cp->canViewPageVersions()) {
$c->loadVersionObject(\Core::make('helper/security')->sanitizeInt($_REQUEST['cvID']));
$spoofed_request = \Request::createFromGlobals();
if ($device_handle = $request->headers->get('x-device-handle')) {
if ($device = \Core::make('device/manager')->get($device_handle)) {
if ($agent = $device->getUserAgent()) {
$spoofed_request->headers->set('User-Agent', $agent);
}
}
}
$spoofed_request->setCustomRequestUser(-1);
$spoofed_request->setCurrentPage($c);
\Request::setInstance($spoofed_request);
$controller = $c->getPageController();
$controller->runTask('view', array());
$view = $controller->getViewObject();
$response = new \Response();
$content = $view->render();
// Reset just in case.
\Request::setInstance($request);
$response->setContent($content);
$response->send();
exit;
}
}
示例7: hookRequest
/**
* @mcms_message ru.molinos.cms.page.content
*/
public static function hookRequest(Context $ctx)
{
if (true === self::isLocked($ctx)) {
$r = new Response(t('На сервере ведутся технические работы, обратитесь чуть позже.'), 'text/plain', 503);
$r->send();
}
}
示例8: error
public static function error($message, $status = 501)
{
Event::trigger('api.error', [$message, $status]);
Response::status($status);
Response::json(['error' => ['type' => 'fatal', 'status' => $status, 'message' => $message]]);
Response::send();
exit;
}
示例9: dispatch
public function dispatch(Route $route, Request $request, Response $response)
{
$controller = __NAMESPACE__ . '\\Controllers\\' . $route->getController();
$action = $route->getAction();
$foo = new $controller($request, $response);
$foo->{$action}();
$response->send();
}
示例10: run
/**
* 执行应用程序
* @access public
* @return void
*/
public static function run()
{
// 注册错误和异常处理机制 以及初始化配置
register_shutdown_function('\\think\\Error::appShutdown');
set_error_handler('\\think\\Error::appError');
set_exception_handler('\\think\\Error::appException');
Config::load(THINK_PATH . 'config' . EXT);
// 初始化应用(公共模块) 初始化变量配置
self::initModule(COMMON_MODULE, Config::get());
// 获取配置参数
$config = Config::get();
// 设置系统时区
date_default_timezone_set($config['default_timezone']);
// 监听app_init
APP_HOOK && Hook::listen('app_init');
// 开启多语言机制
// 启动session CLI 不开启
if (!IS_CLI && $config['use_session']) {
Session::init($config['session']);
}
if (empty(self::$dispatch['type'])) {
// 未指定调度类型 则进行URL路由检测
self::route($config);
}
// 记录路由信息
APP_DEBUG && Log::record('[ ROUTE ] ' . var_export(self::$dispatch, true), 'info');
// 监听app_begin
APP_HOOK && Hook::listen('app_begin');
// 根据类型调度
switch (self::$dispatch['type']) {
case 'redirect':
// 执行重定向跳转
header('Location: ' . self::$dispatch['url'], true, self::$dispatch['status']);
break;
case 'module':
// 模块/控制器/操作
$data = self::module(self::$dispatch['module'], $config);
break;
case 'controller':
// 执行控制器操作
//$data = Loader::action(self::$dispatch['controller'], self::$dispatch['params']);
break;
case 'method':
// 执行回调方法
$data = self::invokeMethod(self::$dispatch['method'], self::$dispatch['params']);
break;
case 'function':
// 规则闭包
$data = self::invokeFunction(self::$dispatch['function'], self::$dispatch['params']);
break;
default:
throw new Exception('dispatch type not support', 10008);
}
// 监听app_end
APP_HOOK && Hook::listen('app_end', $data);
// 输出数据到客户端
return Response::send($data, Response::type(), Config::get('response_return'));
}
示例11: show
function show()
{
$configuration = new Config();
$database = new SafeMySQL(array('user' => $configuration->db->username, 'pass' => $configuration->db->password, 'db' => $configuration->db->database, 'charset' => $configuration->db->charset));
$data = $database->getAll('SELECT * FROM students');
$response = new Response();
$response->setContent(json_encode($data));
$response->send();
}
示例12: about
function about(Request $request, Response $response)
{
$this->v->set_tplname('mod_default_about');
$this->nav_flag1 = 'about';
if ($request->is_hashreq()) {
} else {
}
$response->send($this->v);
}
示例13: viaJavaScript
public static function viaJavaScript($url, $parent = false)
{
if ($link = Filter::with('core.redirect', $url)) {
Response::type('text/html');
Response::add('<script>' . ($parent ? 'parent.' : '') . 'location.href="', addslashes($link), '"</script>');
Response::send();
exit;
}
}
示例14: returnSuccess
protected function returnSuccess($data, $message = null)
{
$res = new Response();
$res->success = true;
$res->data = $data;
$res->message = $message;
$res->send();
exit;
}
示例15: send
public function send()
{
$location = $this->location;
if (!preg_match('#^https?://#', $location)) {
$location = $this->getSchema() . '://' . $_SERVER['HTTP_HOST'] . $location;
}
$this->addHeader('Location: ' . $location);
parent::send();
}