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


PHP Router::setRequestInfo方法代码示例

本文整理汇总了PHP中Cake\Routing\Router::setRequestInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::setRequestInfo方法的具体用法?PHP Router::setRequestInfo怎么用?PHP Router::setRequestInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Routing\Router的用法示例。


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

示例1: __construct

 public function __construct($request = null, $response = null)
 {
     $request->webroot = '/';
     Router::setRequestInfo($request);
     parent::__construct($request, $response);
 }
开发者ID:arourke,项目名称:UserPermissions,代码行数:6,代码来源:UserPermissionComponentTest.php

示例2: __construct

 /**
  * construct method
  */
 public function __construct($request = null, $response = null)
 {
     $request->addParams(Router::parse('/auth_test'));
     $request->here = '/auth_test';
     $request->webroot = '/';
     Router::setRequestInfo($request);
     parent::__construct($request, $response);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:11,代码来源:AuthTestController.php

示例3: beforeDispatch

 /**
  * Applies Routing and additionalParameters to the request to be dispatched.
  * If Routes have not been loaded they will be loaded, and config/routes.php will be run.
  *
  * @param \Cake\Event\Event $event containing the request, response and additional params
  * @return void
  */
 public function beforeDispatch(Event $event)
 {
     $request = $event->data['request'];
     Router::setRequestInfo($request);
     if (empty($request->params['controller'])) {
         $params = Router::parse($request->url);
         $request->addParams($params);
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:16,代码来源:RoutingFilter.php

示例4: setUp

 /**
  * SetUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Configure::delete('Passwordable');
     Configure::write('Passwordable.auth', 'AuthTest');
     $this->Users = TableRegistry::get('ToolsUsers');
     $this->hasher = PasswordHasherFactory::build('Default');
     Router::setRequestInfo(new Request());
 }
开发者ID:dereuromark,项目名称:cakephp-tools,代码行数:15,代码来源:PasswordableBehaviorTest.php

示例5: filterRequest

 /**
  * Filters the BrowserKit request to the cake one.
  *
  * @param \Symfony\Component\BrowserKit\Request $request BrowserKit request.
  * @return \Cake\Network\Request Cake request.
  */
 protected function filterRequest(\Symfony\Component\BrowserKit\Request $request)
 {
     $url = preg_replace('/^https?:\\/\\/[a-z0-9\\-\\.]+/', '', $request->getUri());
     $_ENV = $environment = ['REQUEST_METHOD' => $request->getMethod()] + $request->getServer();
     $props = ['url' => $url, 'post' => (array) $request->getParameters(), 'files' => (array) $request->getFiles(), 'cookies' => (array) $request->getCookies(), 'session' => $this->getSession(), 'environment' => $environment];
     $this->cake['request'] = new Request($props);
     // set params
     Router::setRequestInfo($this->cake['request']);
     $this->cake['request']->params = Router::parse($url);
     return $this->cake['request'];
 }
开发者ID:cakephp,项目名称:codeception,代码行数:17,代码来源:Connector.php

示例6: setUp

 /**
  * setup create a request object to get out of router later.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::reload();
     $request = new Request();
     $request->base = '';
     Router::setRequestInfo($request);
     Configure::write('debug', true);
     $this->_logger = $this->getMock('Psr\\Log\\LoggerInterface');
     Log::reset();
     Log::config('error_test', ['engine' => $this->_logger]);
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:17,代码来源:ErrorHandlerTest.php

示例7: setUp

 /**
  * SetUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Configure::delete('Passwordable');
     Configure::write('Passwordable.auth', 'AuthTest');
     $this->Users = TableRegistry::get('ToolsUsers');
     $this->hasher = PasswordHasherFactory::build('Default');
     $user = $this->Users->newEntity();
     $data = ['id' => '5', 'name' => 'admin', 'password' => $this->hasher->hash('somepwd'), 'role_id' => '1'];
     $this->Users->patchEntity($user, $data);
     $result = $this->Users->save($user);
     $this->assertTrue((bool) $result);
     Router::setRequestInfo(new Request());
 }
开发者ID:olmprakash,项目名称:cakephp-tools,代码行数:20,代码来源:PasswordableBehaviorTest.php

示例8: setUp

 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->request = new Request('posts/index');
     Router::setRequestInfo($this->request);
     $this->response = $this->getMock('Cake\\Network\\Response');
     Security::salt('somerandomhaskeysomerandomhaskey');
     $this->Registry = new ComponentRegistry(new Controller($this->request, $this->response));
     $this->Registry->load('Cookie');
     $this->Registry->load('Auth');
     $this->auth = new CookieAuthenticate($this->Registry, ['fields' => ['username' => 'user_name', 'password' => 'password'], 'userModel' => 'MultiUsers']);
     $password = password_hash('password', PASSWORD_DEFAULT);
     $MultiUsers = TableRegistry::get('MultiUsers');
     $MultiUsers->updateAll(['password' => $password], []);
 }
开发者ID:friendsofcake,项目名称:authenticate,代码行数:20,代码来源:CookieAuthenticateTest.php

示例9: setUp

 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->request = new Request('posts/index');
     Router::setRequestInfo($this->request);
     $this->response = $this->getMock('Cake\\Network\\Response');
     Security::salt('Xety-Cake3CookieAuth_Xety-Cake3CookieAuth');
     $this->registry = new ComponentRegistry(new Controller($this->request, $this->response));
     $this->registry->load('Cookie');
     $this->registry->load('Auth');
     $this->auth = new CookieAuthenticate($this->registry);
     $password = password_hash('password', PASSWORD_DEFAULT);
     $Users = TableRegistry::get('Users');
     $Users->updateAll(['password' => $password], []);
 }
开发者ID:xety,项目名称:cake3-cookieauth,代码行数:20,代码来源:CookieAuthenticateTest.php

示例10: beforeDispatch

 /**
  * Applies Routing and additionalParameters to the request to be dispatched.
  * If Routes have not been loaded they will be loaded, and config/routes.php will be run.
  *
  * @param \Cake\Event\Event $event containing the request, response and additional params
  * @return void|Cake\Network\Response A response will be returned when a redirect route is encountered.
  */
 public function beforeDispatch(Event $event)
 {
     $request = $event->data['request'];
     Router::setRequestInfo($request);
     try {
         if (empty($request->params['controller'])) {
             $params = Router::parse($request->url);
             $request->addParams($params);
         }
     } catch (RedirectException $e) {
         $response = $event->data['response'];
         $response->statusCode($e->getCode());
         $response->header('Location', $e->getMessage());
         return $response;
     }
 }
开发者ID:MillHidden,项目名称:BiellesMeusiennes,代码行数:23,代码来源:RoutingFilter.php

示例11: testBeforeRedirectCallbackWithArrayUrl

 /**
  * test that the beforeRedirect callback properly converts
  * array URLs into their correct string ones, and adds base => false so
  * the correct URLs are generated.
  *
  * @link https://cakephp.lighthouseapp.com/projects/42648-cakephp-1x/tickets/276
  * @return void
  * @triggers Controller.beforeRender $this->Controller
  */
 public function testBeforeRedirectCallbackWithArrayUrl()
 {
     Configure::write('App.namespace', 'TestApp');
     Router::connect('/:controller/:action/*');
     $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     $event = new Event('Controller.beforeRender', $this->Controller);
     Router::setRequestInfo([['plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => []], ['base' => '', 'here' => '/accounts/', 'webroot' => '/']]);
     $RequestHandler = new RequestHandlerComponent($this->Controller->components());
     $RequestHandler->request = new Request('posts/index');
     $RequestHandler->response = $this->Controller->response;
     ob_start();
     $RequestHandler->beforeRedirect($event, ['controller' => 'RequestHandlerTest', 'action' => 'param_method', 'first', 'second'], $this->Controller->response);
     $result = ob_get_clean();
     $this->assertEquals('one: first two: second', $result);
 }
开发者ID:Slayug,项目名称:castor,代码行数:24,代码来源:RequestHandlerComponentTest.php

示例12: testRedirectUrlWithBaseSet

 /**
  * test that the returned URL doesn't contain the base URL.
  *
  * @see https://cakephp.lighthouseapp.com/projects/42648/tickets/3922-authcomponentredirecturl-prepends-appbaseurl
  *
  * @return void This test method doesn't return anything.
  */
 public function testRedirectUrlWithBaseSet()
 {
     $App = Configure::read('App');
     Configure::write('App', ['dir' => APP_DIR, 'webroot' => 'webroot', 'base' => false, 'baseUrl' => '/cake/index.php']);
     $url = '/users/login';
     $this->Auth->request = $this->Controller->request = new Request($url);
     $this->Auth->request->addParams(Router::parse($url));
     $this->Auth->request->url = Router::normalize($url);
     Router::setRequestInfo($this->Auth->request);
     $this->Auth->config('loginAction', ['controller' => 'users', 'action' => 'login']);
     $this->Auth->config('loginRedirect', ['controller' => 'users', 'action' => 'home']);
     $result = $this->Auth->redirectUrl();
     $this->assertEquals('/users/home', $result);
     $this->assertFalse($this->Auth->session->check('Auth.redirect'));
     Configure::write('App', $App);
     Router::reload();
 }
开发者ID:Rabp9,项目名称:test-psi2,代码行数:24,代码来源:AuthComponentTest.php

示例13: testUrlWithRequestAction

 /**
  * Test that Router::url() uses the first request
  */
 public function testUrlWithRequestAction()
 {
     Router::connect('/:controller', array('action' => 'index'));
     Router::connect('/:controller/:action');
     $firstRequest = new Request('/posts/index');
     $firstRequest->addParams(array('plugin' => null, 'controller' => 'posts', 'action' => 'index'))->addPaths(array('base' => ''));
     $secondRequest = new Request('/posts/index');
     $secondRequest->addParams(array('requested' => 1, 'plugin' => null, 'controller' => 'comments', 'action' => 'listing'))->addPaths(array('base' => ''));
     Router::setRequestInfo($firstRequest);
     Router::setRequestInfo($secondRequest);
     $result = Router::url(array('_base' => false));
     $this->assertEquals('/comments/listing', $result, 'with second requests, the last should win.');
     Router::popRequest();
     $result = Router::url(array('_base' => false));
     $this->assertEquals('/posts', $result, 'with second requests, the last should win.');
     // Make sure that popping an empty request doesn't fail.
     Router::popRequest();
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:21,代码来源:RouterTest.php

示例14: testRequestActionBaseAndWebroot

 /**
  * Test that requestAction() is populates the base and webroot properties properly
  *
  * @return void
  */
 public function testRequestActionBaseAndWebroot()
 {
     $request = new Request(['base' => '/subdir', 'webroot' => '/subdir/']);
     Router::setRequestInfo($request);
     $result = $this->object->requestAction('/request_action/params_pass');
     $result = json_decode($result, true);
     $this->assertEquals($request->base, $result['base']);
     $this->assertEquals($request->webroot, $result['webroot']);
 }
开发者ID:Slayug,项目名称:castor,代码行数:14,代码来源:RequestActionTraitTest.php

示例15: parseParams

 /**
  * Applies Routing and additionalParameters to the request to be dispatched.
  * If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.
  *
  * @param \Cake\Event\Event $event containing the request, response and additional params
  * @return void
  */
 public function parseParams(Event $event)
 {
     $request = $event->data['request'];
     Router::setRequestInfo($request);
     if (empty($request->params['controller'])) {
         $params = Router::parse($request->url);
         $request->addParams($params);
     }
     if (!empty($event->data['additionalParams'])) {
         $request->addParams($event->data['additionalParams']);
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:19,代码来源:Dispatcher.php


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