作者:kellian
项目:TestZill
/**
* Get CSRF token for Ajax request.
* @return a HTTP response object with JSON
*/
public function getCsrfTokenAction()
{
$result = array('csrfTokenKey' => $this->security->getTokenKey(), 'csrfToken' => $this->security->getToken());
$response = new Response();
$response->setContent(json_encode($result));
return $response;
}
作者:boorly
项目:friendsAp
public function returnResult($result, $errorMessage = null)
{
$response = new Response();
$result = ['result' => $result, 'status' => $errorMessage === null ? self::SUCCESS_RESPONSE : self::FAILED_RESPONSE, 'error_message' => (string) $errorMessage];
$response->setJsonContent($result);
return $response;
}
作者:hushibin
项目:EvaEngin
/**
*
*/
public function setUp()
{
$di = new DI();
$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/path?foo=aaa&bar=bbb';
$_GET = array('_url' => '/path', 'foo' => 'aaa', 'bar' => 'bbb');
$request = new Request();
$request->setDI($di);
$this->request = $request;
$response = new Response();
$response->setDI($di);
$dispatcher = new Dispatcher();
$dispatcher->setDI($di);
$this->dispatcher = $dispatcher;
$cache = new BackendCache(new FrontendCache());
$di->set('viewCache', $cache);
$config = new Config(array('cache' => array('enable' => true)));
$di->set('config', $config);
$eventsManager = new Manager();
$di->set('request', $request, true);
$di->set('response', $response, true);
$di->set('dispatcher', $dispatcher, true);
$di->set('eventsManager', $eventsManager);
$this->di = $di;
$application = new Application();
$application->setDI($di);
$application->setEventsManager($eventsManager);
$this->application = $application;
}
作者:carriercom
项目:Phast
public function rawAction()
{
$plain_response = new Response();
$plain_response->setHeader("Content-Type", "text/plain");
$plain_response->setContent($this->paste->content);
return $plain_response;
}
作者:evaengin
项目:evaengin
public function setUp()
{
$di = new DI();
$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/path?foo=aaa&bar=bbb';
$_GET = array('_url' => '/path', 'foo' => 'aaa', 'bar' => 'bbb');
$request = new Request();
$request->setDI($di);
$this->request = $request;
$response = new Response();
$response->setDI($di);
$this->response = $response;
$eventsManager = new Manager();
$cors = new Cors(array(array('domain' => 'bar.com')));
$di->set('request', $request, true);
$di->set('response', $response, true);
$di->set('eventsManager', $eventsManager);
$di->set('cors', $cors);
$this->di = $di;
$application = new Application();
$application->setDI($di);
$application->setEventsManager($eventsManager);
$this->application = $application;
}
作者:aisuhu
项目:vkpla
/**
* @param View $view
*/
protected function _renderJsonp(View $view)
{
$content = $this->getResponse()->setContentType('application/json')->setJsonContent($view->getParamsToView())->getContent();
$content = $this->request->get('callback') . '(' . $content . ')';
$this->response->setContent($content)->send();
$view->setRenderLevel(View::LEVEL_NO_RENDER);
}
作者:kjmtru
项目:phanboo
public function uploadAction()
{
$this->mediaModel = new Media();
if ($this->request->hasFiles() == true) {
$uploads = $this->request->getUploadedFiles();
$this->view->disable();
$uploaded = true;
foreach ($uploads as $fileObj) {
if (!$this->mediaModel->initFile($fileObj)) {
$uploaded = false;
}
}
$response = new Response();
if (!$uploaded) {
$error = implode("\n", $this->mediaModel->getError());
$response->setStatusCode(406, $error);
} else {
$response->setStatusCode(200, "Success");
}
return $response;
} else {
$this->assets->addCss('/core/assets/css/dropzone.css', false);
$this->assets->addJs('/core/assets/js/dropzone.js', false);
$this->view->acceptExt = implode(",", $this->constants->mediaAcceptFilesExt());
}
}
作者:caiofralmeid
项目:soccer-company-even
protected function jsonResponse($data)
{
$response = new Response();
$response->setContentType('application/json', 'UTF-8');
$response->setJsonContent($data);
return $response;
}
作者:serus2
项目:phalcon
/**
* @return Response
*/
public function response()
{
if ($this->__response === null) {
$this->__response = new Response();
$this->__response->setStatusCode(200);
}
return $this->__response;
}
作者:josz
项目:Chell-PHP-Porta
/**
* Logout user, destroying session and invalidating remember me cookie. Forwards to login form.
*/
public function logoutAction()
{
$response = new Response();
$response->setCookies($this->cookies->set('username', '', strtotime('-1 year')));
$response->setCookies($this->cookies->set('password', '', strtotime('-1 year')));
$this->session->destroy();
return $response->redirect('session/index');
}
作者:sweetdeve
项目:pingaro
/**
* Returns an Redirect to the given url.
*
* @param string $url
* @return \Phalcon\Http\Response
*/
protected function redirect($url, $extraParams = array())
{
$response = new Response();
$response->redirect($url);
$formReflectionManager = new FormReflectionManager($this->flash);
$formReflectionManager->add($extraParams + $this->request->get());
return $response;
}
作者:halfbakedsnee
项目:phalcor
/**
* Renders the uncaught exception for AJAX consumption.
*
* @param Phalcon\Http\Response $response
* @param \Exception $exceptio
* @return void
*/
protected function renderAJAX(Response $response, Exception $exception)
{
if ($this->config->debug) {
$response->setJsonContent(['_exception' => $exception->getMessage() . ': ' . $exception->getTraceAsString()]);
} else {
$response->setJsonContent(['status' => false]);
}
}
作者:bilna-de
项目:monitoring-tool
/**
* Send response to client
*/
public function respond($data, $status = 200)
{
$response = new Response();
$response->setContentType('application/json');
$response->setStatusCode($status);
$data = $data instanceof SimpleResultSet ? $data->toArray() : $data;
$response->setContent(json_encode($data));
$response->send();
}
作者:rub3nl
项目:webir
/**
* Default action.
*/
public function indexAction()
{
$this->view->disable();
$data = ['Hello', 'World'];
$content = json_encode($data);
$response = new Response();
$response->setContent($content);
return $response;
}
作者:huxiaoh
项目:api-framewor
/**
* 发送数据
* @param mixed $result
*/
private static function sendResult($result)
{
$response = new Response();
$response->setHeader('Content-Type', 'application/json; charset=UTF-8');
$response->setHeader('Access-Control-Allow-Origin', '*');
$response->setJsonContent($result);
$response->send();
exit;
}
作者:mz
项目:phalcon-datatable
public function sendResponse()
{
if ($this->di->has('view')) {
$this->di->get('view')->disable();
}
$response = new Response();
$response->setContentType('application/json', 'utf8');
$response->setJsonContent($this->getResponse());
$response->send();
}
作者:minhlaole
项目:phalcon-debugba
public function handleAction()
{
$debugbar = $this->debugbar;
$debugbar->enable();
$openHandler = new OpenHandler($debugbar);
$data = $openHandler->handle(null, false, false);
$response = new Response($data, 200);
$response->setHeader('Content-Type', 'application/json');
return $response;
}
作者:leyrie
项目:allocuisto_de
public function debugEnvAction()
{
//var_dump($_SERVER['REDIRECT_URL']);die();
$actual_route = $_SERVER['REDIRECT_URL'];
$response = new Response();
$response->setStatusCode(404, "Not Found");
$response->setContent("Sorry, the route: <b>" . $actual_route . " </b> doesn't exist");
$response->send();
return $response;
}
作者:kjmtru
项目:phalcon-ti
/**
* @return Response
*/
public function previewAction()
{
$response = new Response();
if ($this->request->isPost()) {
if ($this->session->get('identity')) {
$content = $this->request->getPost('content');
$response->setContent($this->markdown->render($this->escaper->escapeHtml($content)));
}
}
return $response;
}
作者:a3aremb
项目:phptes
public function indexAction($name)
{
$response = new Response();
$this->getData($name);
if (!$this->result) {
$response->setJsonContent(array('status' => 'NOT-FOUND'));
} else {
$response->setJsonContent(array('status' => 'FOUND', 'data' => $this->result));
}
return $response;
}