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


PHP Network\Request类代码示例

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


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

示例1: getData

 /**
  * Get data of the request
  *
  * @param Request $request
  * @return array
  */
 public function getData(Request $request)
 {
     $data = $request->data('attributes');
     if ($request->data('id')) {
         $data['id'] = $request->data('id');
     }
     return $data;
 }
开发者ID:cakeplugins,项目名称:api,代码行数:14,代码来源:JsonApiParser.php

示例2: __construct

 /**
  * Permission extract constructor.
  *
  * @param $user
  * @param Request $request
  */
 public function __construct($user, Request $request)
 {
     $this->_request = $request;
     $this->_user = (array) $user;
     $this->_requestPref = $request->param('prefix');
     $this->_controller = $request->param('Controller');
     $this->_setAclPlugins();
     $this->_setupAllowed();
 }
开发者ID:Cheren,项目名称:union,代码行数:15,代码来源:PermissionExtract.php

示例3: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::connect('/:controller/:action');
     $request = new Request();
     $request->addParams(array('controller' => 'pages', 'action' => 'display'));
     $this->View = new View($request);
     $this->Toolbar = new ToolbarHelper($this->View);
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:14,代码来源:ToolbarHelperTest.php

示例4: testAuthorizeCheckFailure

 /**
  * test check() failing
  *
  * @return void
  */
 public function testAuthorizeCheckFailure()
 {
     $request = new Request('posts/index');
     $request->addParams(['controller' => 'posts', 'action' => 'index']);
     $user = ['Users' => ['username' => 'mark']];
     $this->_mockAcl();
     $this->Acl->expects($this->once())->method('check')->with($user, 'Posts', 'read')->will($this->returnValue(false));
     $this->assertFalse($this->auth->authorize($user['Users'], $request));
 }
开发者ID:cakephp,项目名称:acl,代码行数:14,代码来源:CrudAuthorizeTest.php

示例5: authorize

 /**
  * User authorize.
  *
  * @param array $user
  * @param Request $request
  * @return bool
  */
 public function authorize($user, Request $request)
 {
     $user = new Data($user);
     //  Allow all for admin role.
     if (Role::ADMIN_ID == $user->get('role_id', Role::PUBLIC_ID)) {
         return true;
     }
     return (bool) $request->param('allowed');
 }
开发者ID:UnionCMS,项目名称:Community,代码行数:16,代码来源:BaseAuthorize.php

示例6: _checkFields

 /**
  * Checks the fields to ensure they are supplied.
  *
  * @param \Cake\Network\Request $request The request that contains login information.
  * @param array $fields The fields to be checked.
  * @return bool False if the fields have not been supplied. True if they exist.
  */
 protected function _checkFields(Request $request, array $fields)
 {
     foreach ([$fields['username'], $fields['password']] as $field) {
         $value = $request->data($field);
         if (empty($value) || !is_string($value)) {
             return false;
         }
     }
     return true;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:17,代码来源:FormAuthenticate.php

示例7: testBeforeDispatchSkipWhenControllerSet

 /**
  * test setting parameters in beforeDispatch method
  *
  * @return void
  * @triggers __CLASS__ $this, compact(request)
  */
 public function testBeforeDispatchSkipWhenControllerSet()
 {
     $filter = new RoutingFilter();
     $request = new Request("/testcontroller/testaction/params1/params2/params3");
     $request->addParams(['controller' => 'articles']);
     $event = new Event(__CLASS__, $this, compact('request'));
     $filter->beforeDispatch($event);
     $this->assertSame($request->params['controller'], 'articles');
     $this->assertEmpty($request->params['action']);
 }
开发者ID:Slayug,项目名称:castor,代码行数:16,代码来源:RoutingFilterTest.php

示例8: testAuthenticateTokenHeader

 /**
  * test authenticate token as request header
  *
  * @return void
  */
 public function testAuthenticateTokenHeader()
 {
     $request = new Request('posts/index');
     $expected = ['id' => 1, 'user_name' => 'mariano', 'email' => 'mariano@example.com', 'token' => '12345', 'created' => new Time('2007-03-17 01:16:23'), 'updated' => new Time('2007-03-17 01:18:31')];
     $request->env('HTTP_X_APITOKEN', '12345');
     $result = $this->auth->getUser($request, $this->response);
     $this->assertEquals($expected, $result);
     $request->env('HTTP_X_APITOKEN', '66666');
     $result = $this->auth->getUser($request, $this->response);
     $this->assertFalse($result);
 }
开发者ID:friendsofcake,项目名称:authenticate,代码行数:16,代码来源:TokenAuthenticateTest.php

示例9: authorize

 /**
  * Hands authorization over to the AnnAuthorize class.
  * @param array $user
  *         An array containing information about the user to authorize.
  * @param Request $request
  *         Describes the request to authorize.
  */
 public function authorize($user, Request $request)
 {
     $controller = $this->_registry->getController();
     $action = $request->param('action');
     $pass = $request->param('pass');
     Log::debug(sprintf('Trying to authorize user %s for request %s/%s and parameters %s.', $user['username'], $controller->name, $action, json_encode($pass)));
     $annAuthorization = AnnAuthorization::getInstance();
     $authorized = $annAuthorization->authorizeRequest($user['id'], $controller, $action, $pass, $request);
     Log::debug(sprintf('Authorization %s', $authorized ? 'was successful.' : 'failed.'));
     return $authorized;
 }
开发者ID:michaelze,项目名称:cakephp-annauthorize,代码行数:18,代码来源:AnnAuthorize.php

示例10: 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 = '';
     $request->env('HTTP_REFERER', '/referer');
     Router::setRequestInfo($request);
     Configure::write('debug', true);
     $this->_logger = $this->getMock('Psr\\Log\\LoggerInterface');
     Log::reset();
     Log::config('error_test', ['engine' => $this->_logger]);
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:18,代码来源:ErrorHandlerTest.php

示例11: _getCredentials

 /**
  * Get user's credentials (username and password) from either session or request data
  *
  * @param Request $request Request instance
  * @return array|bool
  */
 protected function _getCredentials(Request $request)
 {
     $credentials = [];
     foreach (['username', 'password'] as $field) {
         if (!($credentials[$field] = $request->data($this->_config['fields'][$field]))) {
             $credentials[$field] = $this->_decrypt($request->session()->read('TwoFactorAuth.credentials.' . $field));
         }
         if (empty($credentials[$field]) || !is_string($credentials[$field])) {
             return false;
         }
     }
     return $credentials;
 }
开发者ID:andrej-griniuk,项目名称:cakephp-two-factor-auth,代码行数:19,代码来源:FormAuthenticate.php

示例12: get

 /**
  * Check and get current theme.
  *
  * @param Request $request
  * @return string|null
  */
 public static function get(Request $request)
 {
     $theme = Configure::read('Theme.site');
     if ($request->param('prefix') == 'admin') {
         $theme = Configure::read('Theme.admin');
     }
     $path = self::_find($theme);
     if ($path !== null) {
         self::loadList([$theme]);
         return $theme;
     }
     return null;
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:19,代码来源:Theme.php

示例13: authenticate

 /**
  * Authenticate callback
  * Reads the stored cookie and auto login the user
  *
  * @param Request $request Cake request object.
  * @param Response $response Cake response object.
  * @return mixed
  */
 public function authenticate(Request $request, Response $response)
 {
     $cookieName = Configure::read('Users.RememberMe.Cookie.name');
     if (!$this->_registry->Cookie->check($cookieName)) {
         return false;
     }
     $cookie = $this->_registry->Cookie->read($cookieName);
     $this->config('fields.username', 'id');
     $user = $this->_findUser($cookie['id']);
     if ($user && !empty($cookie['user_agent']) && $request->header('User-Agent') === $cookie['user_agent']) {
         return $user;
     }
     return false;
 }
开发者ID:OrigamiStructures,项目名称:users,代码行数:22,代码来源:RememberMeAuthenticate.php

示例14: check

 /**
  * Check if the user can access to the given URL.
  *
  * @param array $params The params to check.
  *
  * @return bool
  */
 public function check(array $params = [])
 {
     if (!$this->request->session()->read('Auth.User')) {
         return false;
     }
     $params += ['_base' => false];
     $url = Router::url($params);
     $params = Router::parse($url);
     $user = [$this->Authorize->config('userModel') => $this->request->session()->read('Auth.User')];
     $request = new Request();
     $request->addParams($params);
     $action = $this->Authorize->action($request);
     return $this->Acl->check($user, $action);
 }
开发者ID:Xety,项目名称:Xeta,代码行数:21,代码来源:AclHelper.php

示例15: validate

 /**
  * {@inheritDoc}
  */
 public function validate(Request $request)
 {
     if ($request->is('post')) {
         // The (User's) Remote Address
         $whatRemoteIP = env('REMOTE_ADDR') ? '&remoteip=' . env('REMOTE_ADDR') : '';
         // The reCAPTCHA data is extracted from Request
         $gRecaptchaResponse = $request->data('g-recaptcha-response');
         // Verify reCAPTCHA data
         $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $this->config('secretKey') . '&response=' . $gRecaptchaResponse . $whatRemoteIP);
         $response = json_decode($response, true);
         // We return the Google server's response 'success' value
         return (bool) $response['success'];
     }
     return false;
 }
开发者ID:quickapps-plugins,项目名称:captcha,代码行数:18,代码来源:RecaptchaAdapter.php


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