本文整理汇总了PHP中Cake\Network\Response::location方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::location方法的具体用法?PHP Response::location怎么用?PHP Response::location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Network\Response
的用法示例。
在下文中一共展示了Response::location方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRedirect
/**
* Manage redirect for specific buttons that posted.
*
* @param Event $event
* @param array|string $url
* @param Response $response
* @return bool
*/
public function beforeRedirect(Event $event, $url, Response $response)
{
if ($this->request->param('prefix') == 'admin') {
if (isset($this->request->data['apply'])) {
$response->location(Router::url($this->request->here(false), true));
}
}
return true;
}
示例2: _verifyCode
/**
* Verify one-time code. If code not provided - redirect to verifyAction. If code provided and is not valid -
* set flash message and redirect to verifyAction. Otherwise - return true.
*
* @param string $secret user's secret
* @param string $code one-time code
* @param Response $response response instance
* @var AuthComponent $Auth used Auth component
* @return bool
* @throws Exception
*/
protected function _verifyCode($secret, $code, Response $response)
{
$Auth = $this->_registry->getController()->Auth;
if (!$Auth instanceof AuthComponent) {
throw new Exception('TwoFactorAuth.Auth component has to be used for authentication.');
}
$verifyAction = Router::url($Auth->config('verifyAction'), true);
if ($code === null) {
$response->location($verifyAction);
return false;
}
if (!$Auth->verifyCode($secret, $code)) {
$Auth->flash(__d('TwoFactorAuth', 'Invalid two-step verification code.'));
$response->location($verifyAction);
return false;
}
return true;
}
示例3: testLocation
/**
* Test the location method.
*
* @return void
*/
public function testLocation()
{
$response = new Response();
$this->assertNull($response->location(), 'No header should be set.');
$this->assertNull($response->location('http://example.org'), 'Setting a location should return null');
$this->assertEquals('http://example.org', $response->location(), 'Reading a location should return the value.');
}
示例4: unauthenticated
/**
* Handles unauthenticated access attempts. Will automatically forward to the
* requested provider's authorization URL to let the user grant access to the
* application.
*
* @param \Cake\Network\Request $request Request object.
* @param \Cake\Network\Response $response Response object.
* @return \Cake\Network\Response|null
*/
public function unauthenticated(Request $request, Response $response)
{
$provider = $this->provider($request);
if (empty($provider) || !empty($request->query['code'])) {
return null;
}
if ($this->config('options.state')) {
$request->session()->write('oauth2state', $provider->getState());
}
$response->location($provider->getAuthorizationUrl());
return $response;
}