當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。