当前位置: 首页>>代码示例>>PHP>>正文


PHP CakeResponse类代码示例

本文整理汇总了PHP中CakeResponse的典型用法代码示例。如果您正苦于以下问题:PHP CakeResponse类的具体用法?PHP CakeResponse怎么用?PHP CakeResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CakeResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * Parses a string url into an array. Parsed urls will result in an automatic
  * redirection
  *
  * @param string $url The url to parse
  * @return boolean False on failure
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if ($params === false) {
         return false;
     }
     $Domains = new Domains();
     $subdomain = $Domains->getSubdomain();
     $masterDomain = Configure::read('Domain.Master');
     $defaultRoute = Configure::read('Domain.DefaultRoute');
     $Tenant = new Tenant();
     if (!$Tenant->domainExists($subdomain) && $params != $defaultRoute) {
         if (!$this->response) {
             $this->response = new CakeResponse();
         }
         debug($this->response);
         die;
         $status = 307;
         $redirect = $defaultRoute;
         $this->response->header(array('Location' => Router::url($redirect, true)));
         $this->response->statusCode($status);
         $this->response->send();
         $this->_stop();
     }
     return $subdomain;
 }
开发者ID:bmilesp,项目名称:multi-tenancy,代码行数:33,代码来源:DomainRoute.php

示例2: authenticate

 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $provider = new Stevenmaguire\OAuth2\Client\Provider\Bitbucket(array('clientId' => Configure::read('OAuth.bitbucket_consumer_key'), 'clientSecret' => Configure::read('OAuth.bitbucket_consumer_secret'), 'redirectUri' => Configure::read('OAuth.redirect_uri')));
     $session = new CakeSession();
     if (!isset($request->query['code'])) {
         $response->header('Location', $provider->getAuthorizationUrl());
     } else {
         try {
             $token = $provider->getAccessToken('authorization_code', array('code' => $request->query['code']));
         } catch (Exception $e) {
             return false;
         }
         $resourceOwner = $provider->getResourceOwner($token)->toArray();
         App::uses('User', 'Model');
         $User = new User();
         $data = array('User' => array('account_type' => 'bitbucket', 'username' => $resourceOwner['username'], 'display_name' => $resourceOwner['display_name'], 'bitbucket_uuid' => $resourceOwner['uuid'], 'oauth_access_token' => $token->getToken(), 'oauth_refresh_token' => $token->getRefreshToken(), 'oauth_token_expires_in' => $token->getExpires()));
         $existingUser = $User->find('first', array('conditions' => array('User.bitbucket_uuid' => $resourceOwner['uuid'])));
         if (!$existingUser) {
             $User->create();
         } else {
             $data['User']['id'] = $existingUser['User']['id'];
         }
         $User->save($data);
         return $data['User'];
     }
     return false;
 }
开发者ID:Glitchbone,项目名称:yolped,代码行数:27,代码来源:BitbucketAuthenticate.php

示例3: parse

 /**
  * Parses a string url into an array. Parsed urls will result in an automatic
  * redirection
  *
  * @param string $url The url to parse
  * @return boolean False on failure
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if (!$params) {
         return false;
     }
     if (!$this->response) {
         $this->response = new CakeResponse();
     }
     $redirect = $this->defaults;
     if (count($this->defaults) == 1 && !isset($this->defaults['controller'])) {
         $redirect = $this->defaults[0];
     }
     if (isset($this->options['persist']) && is_array($redirect)) {
         $argOptions['context'] = array('action' => $redirect['action'], 'controller' => $redirect['controller']);
         $args = Router::getArgs($params['_args_'], $argOptions);
         $redirect += $args['pass'];
         $redirect += $args['named'];
     }
     $status = 301;
     if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) {
         $status = $this->options['status'];
     }
     $this->response->header(array('Location' => Router::url($redirect, true)));
     $this->response->statusCode($status);
     $this->response->send();
 }
开发者ID:no2key,项目名称:Web-Framework-Benchmark,代码行数:34,代码来源:redirect_route.php

示例4: parse

 /**
  * Parses a string url into an array. Parsed urls will result in an automatic
  * redirection
  *
  * @param string $url The url to parse
  * @return boolean False on failure
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if (!$params) {
         return false;
     }
     if (!$this->response) {
         $this->response = new CakeResponse();
     }
     $redirect = $this->redirect;
     if (count($this->redirect) == 1 && !isset($this->redirect['controller'])) {
         $redirect = $this->redirect[0];
     }
     if (isset($this->options['persist']) && is_array($redirect)) {
         $redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array());
         $redirect = Router::reverse($redirect);
     }
     $status = 301;
     if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) {
         $status = $this->options['status'];
     }
     $this->response->header(array('Location' => Router::url($redirect, true)));
     $this->response->statusCode($status);
     $this->response->send();
     $this->_stop();
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:33,代码来源:RedirectRoute.php

示例5: authenticate

 /**
  * Authenticate user
  *
  * @param CakeRequest $request The request object
  * @param CakeResponse $response response object.
  * @return mixed.  False on login failure.  An array of User data on success.
  */
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $user = $this->getUser($request);
     if (!$user) {
         $response->statusCode(401);
         $response->send();
     }
     return $user;
 }
开发者ID:hardiksondagar,项目名称:cake-jwt-seed,代码行数:16,代码来源:JwtTokenAuthenticate.php

示例6: testReplaceRunId

 /**
  * Test that beforeDispatcher replaces run id
  *
  * @return void
  */
 public function testReplaceRunId()
 {
     $filter = new XHProfDispatcher();
     $response = new CakeResponse();
     $response->body('Run id: %XHProfRunId%.');
     $event = new CakeEvent('DispatcherTest', $this, compact('response'));
     $filter->beforeDispatch($event);
     $this->assertSame($response, $filter->afterDispatch($event));
     $this->assertRegExp('/^Run id: [0-9a-f]{13}\\.$/', $response->body());
 }
开发者ID:renan,项目名称:cakephp-xhprof,代码行数:15,代码来源:XHProfDispacherTest.php

示例7: authenticate

 /**
  * Authenticate a user using basic HTTP auth.  Will use the configured User model and attempt a
  * login using basic HTTP auth.
  *
  * @param CakeRequest $request The request to authenticate with.
  * @param CakeResponse $response The response to add headers to.
  * @return mixed Either false on failure, or an array of user data on success.
  */
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $result = $this->getUser($request);
     if (empty($result)) {
         $response->header($this->loginHeaders());
         $response->statusCode(401);
         $response->send();
         return false;
     }
     return $result;
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:19,代码来源:BasicAuthenticate.php

示例8: insertFile

 /**
  * https://developers.google.com/drive/v2/reference/files/insert
  **/
 public function insertFile($file, $driveFile, $options = array())
 {
     // setting default options
     $options = array_merge(array('convert' => 'true'), $options);
     // seting path and request
     $path = sprintf('/%s', $driveFile['id']);
     $request = array();
     $request['uri']['query'] = $options;
     $request['body'] = file_get_contents($file['tmp_name']);
     // using CakeReponse to guess mime type
     $ext = array_pop(explode('.', $file['name']));
     $CR = new CakeResponse();
     $request['header']['Content-Type'] = $CR->getMimeType($ext);
     return $this->_request($path, $request);
 }
开发者ID:kaburk,项目名称:CakePHP-Google,代码行数:18,代码来源:GoogleDriveFilesUpload.php

示例9: testRenderWithView

 /**
  * testRenderWithView method
  *
  * @return void
  */
 public function testRenderWithView()
 {
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)));
     $Request = new CakeRequest();
     $Response = new CakeResponse();
     $Controller = new Controller($Request, $Response);
     $Controller->name = $Controller->viewPath = 'Posts';
     $data = array('User' => array('username' => 'fake'), 'Item' => array(array('name' => 'item1'), array('name' => 'item2')));
     $Controller->set('user', $data);
     $View = new JsonView($Controller);
     $output = $View->render('index');
     $expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2')));
     $this->assertIdentical($expected, $output);
     $this->assertIdentical('application/json', $Response->type());
 }
开发者ID:rufl,项目名称:ATP,代码行数:20,代码来源:JsonViewTest.php

示例10: testRenderWithView

 /**
  * testRenderWithView method
  *
  * @return void
  */
 public function testRenderWithView()
 {
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)));
     $Request = new CakeRequest();
     $Response = new CakeResponse();
     $Controller = new Controller($Request, $Response);
     $Controller->name = $Controller->viewPath = 'Posts';
     $data = array(array('User' => array('username' => 'user1')), array('User' => array('username' => 'user2')));
     $Controller->set('users', $data);
     $View = new XmlView($Controller);
     $output = $View->render('index');
     $expected = '<?xml version="1.0" encoding="UTF-8"?><users><user>user1</user><user>user2</user></users>';
     $this->assertIdentical($expected, str_replace(array("\r", "\n"), '', $output));
     $this->assertIdentical('application/xml', $Response->type());
     $this->assertInstanceOf('HelperCollection', $View->Helpers);
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:21,代码来源:XmlViewTest.php

示例11: _fetch

 protected function _fetch($facebook, $access_oauth_token, CakeResponse $response)
 {
     try {
         // get user infomation from Facebook
         $user_id = $facebook->getUser();
         $me = $facebook->api('/me');
         $user = $this->_Collection->Auth->user();
         $user['Member']["user_id"] = $me['id'];
         $user['Member']["user_name"] = $me['name'];
         $user['Member']["access_oauth_token"] = $access_oauth_token;
         if ($this->_Collection->Auth->login($user)) {
             $loginRedirect = $this->_Collection->Auth->loginRedirect;
             $response->header('Location', $loginRedirect);
             $response->send();
         }
     } catch (OAuthException $E) {
         //you can catch OAuth exception
     }
 }
开发者ID:noahm,项目名称:cakephp-FacebookAuthenticate,代码行数:19,代码来源:FacebookAuthenticate.php

示例12: _deliverMedia

 protected function _deliverMedia(CakeResponse $response, $mediaFile, $mediaInfo)
 {
     $response->sharable(true, 2592000);
     //$response->mustRevalidate(true);
     $response->expires('+30 days');
     $modTime = filemtime($mediaFile);
     $response->modified($modTime);
     $response->etag(md5($mediaFile . $modTime));
     //$response->header("Pragma", "cache");
     $response->type($mediaInfo['ext']);
     $response->file($mediaFile);
     $response->send();
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:13,代码来源:MediaDispatcher.php

示例13: authenticate

 /**
  *
  * @param CakeRequest $request
  * @param CakeResponse $response
  * @return boolean
  */
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $oauth = ClassRegistry::init('Twim.TwimOauth');
     /* @var $oauth TwimOauth */
     if (!empty($request->data['Twitter']['login'])) {
         // redirect to twitter
         $requestToken = $oauth->getRequestToken();
         $redirectUrl = $this->settings['authenticate'] ? $oauth->getAuthenticateUrl($requestToken) : $oauth->getAuthorizeUrl($requestToken);
         $response->header('Location', $redirectUrl);
     } elseif (isset($request->query['oauth_token']) && isset($request->query['oauth_verifier'])) {
         // get access token
         $verifier = array_intersect_key($request->query, array('oauth_token' => true, 'oauth_verifier' => true));
         $accessToken = $oauth->getAccessToken($verifier);
         if ($this->settings['userModel'] === false) {
             return $accessToken;
         }
         // save user data
         return $this->saveToModel($accessToken);
     }
     return false;
 }
开发者ID:nojimage,项目名称:cakephp-twim,代码行数:27,代码来源:TwitterAuthenticate.php

示例14: _getController

 protected function _getController($exception)
 {
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse();
     if (method_exists($exception, 'responseHeader')) {
         $response->header($exception->responseHeader());
     }
     try {
         $controller = new AppErrorController($request, $response);
         $controller->startupProcess();
     } catch (Exception $e) {
         if (!empty($controller) && $controller->Components->enabled('RequestHandler')) {
             $controller->RequestHandler->startup($controller);
         }
     }
     if (empty($controller)) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:23,代码来源:AppExceptionRenderer.php

示例15: testRenderWithView

 /**
  * testRenderWithView method
  *
  * @return void
  */
 public function testRenderWithView()
 {
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)));
     $Request = new CakeRequest();
     $Response = new CakeResponse();
     $Controller = new Controller($Request, $Response);
     $Controller->name = $Controller->viewPath = 'Posts';
     $data = array(array('User' => array('username' => 'user1')), array('User' => array('username' => 'user2')));
     $Controller->set('users', $data);
     $View = new XmlView($Controller);
     $output = $View->render('index');
     $expected = array('users' => array('user' => array('user1', 'user2')));
     $expected = Xml::build($expected)->asXML();
     $this->assertSame($expected, $output);
     $this->assertSame('application/xml', $Response->type());
     $this->assertInstanceOf('HelperCollection', $View->Helpers);
 }
开发者ID:pritten,项目名称:SmartCitizen.me,代码行数:22,代码来源:XmlViewTest.php


注:本文中的CakeResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。