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


PHP Request::data方法代码示例

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


在下文中一共展示了Request::data方法的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: val

 /**
  * {@inheritDoc}
  */
 public function val($field, $options = [])
 {
     $options += ['default' => null, 'schemaDefault' => true];
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     return $options['default'];
 }
开发者ID:nrother,项目名称:cakephp,代码行数:12,代码来源:FormContext.php

示例3: authenticate

 /**
  * Authenticate a user based on the request information.
  *
  * @param Request $request Request to get authentication information from.
  * @param Response $response A response object that can have headers added.
  * @return array|bool User array on success, false on failure.
  */
 public function authenticate(Request $request, Response $response)
 {
     $fields = $this->_config['fields'];
     if (!$request->data($fields['provider'])) {
         return $this->getUser($request);
     }
     $provider = $this->_checkFields($request, $fields);
     if (!$provider) {
         return false;
     }
     if ($this->_config['hauth_return_to']) {
         $returnTo = Router::url($this->_config['hauth_return_to'], true);
     } else {
         $returnTo = Router::url(['plugin' => 'ADmad/HybridAuth', 'controller' => 'HybridAuth', 'action' => 'authenticated'], true);
     }
     $params = ['hauth_return_to' => $returnTo];
     if ($provider === 'OpenID') {
         $params['openid_identifier'] = $request->data[$fields['openid_identifier']];
     }
     $this->_init($request);
     $adapter = $this->hybridAuth->authenticate($provider, $params);
     if ($adapter) {
         return $this->_getUser($provider, $adapter);
     }
     return false;
 }
开发者ID:jamiefifty,项目名称:CakePHP-HybridAuth,代码行数:33,代码来源:HybridAuthAuthenticate.php

示例4: val

 /**
  * Get the value for a given path.
  *
  * Traverses the entity data and finds the value for $path.
  *
  * @param string $field The dot separated path to the value.
  * @param array $options Options:
  *   - `default`: Default value to return if no value found in request
  *     data or entity.
  *   - `schemaDefault`: Boolen indicating whether default value from table
  *     schema should be used if it's not explicitly provided.
  * @return mixed The value of the field or null on a miss.
  */
 public function val($field, $options = [])
 {
     $options += ['default' => null, 'schemaDefault' => true];
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     if (empty($this->_context['entity'])) {
         return $options['default'];
     }
     $parts = explode('.', $field);
     $entity = $this->entity($parts);
     if (end($parts) === '_ids' && !empty($entity)) {
         return $this->_extractMultiple($entity, $parts);
     }
     if ($entity instanceof EntityInterface) {
         $part = array_pop($parts);
         $val = $entity->get($part);
         if ($val !== null) {
             return $val;
         }
         if ($options['default'] !== null || !$options['schemaDefault'] || !$entity->isNew()) {
             return $options['default'];
         }
         return $this->_schemaDefault($part, $entity);
     }
     if (is_array($entity)) {
         $key = array_pop($parts);
         return isset($entity[$key]) ? $entity[$key] : null;
     }
     return null;
 }
开发者ID:ramb0Ram,项目名称:cakephp,代码行数:45,代码来源:EntityContext.php

示例5: _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

示例6: val

 /**
  * Get the current value for a given field.
  *
  * This method will coalesce the current request data and the 'defaults'
  * array.
  *
  * @param string $field A dot separated path to the field a value
  *   is needed for.
  * @return mixed
  */
 public function val($field)
 {
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     if (empty($this->_context['defaults']) || !is_array($this->_context['defaults'])) {
         return null;
     }
     return Hash::get($this->_context['defaults'], $field);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:21,代码来源:ArrayContext.php

示例7: _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

示例8: val

 /**
  * {@inheritDoc}
  */
 public function val($field)
 {
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     if (empty($this->_context['entity'])) {
         return null;
     }
     $parts = explode('.', $field);
     $entity = $this->entity($parts);
     if ($entity instanceof Document) {
         return $entity->get(array_pop($parts));
     }
 }
开发者ID:jeffersongoncalves,项目名称:elastic-search,代码行数:18,代码来源:DocumentContext.php

示例9: val

 /**
  * Get the current value for a given field.
  *
  * This method will coalesce the current request data and the 'defaults'
  * array.
  *
  * @param string $field A dot separated path to the field a value
  *   is needed for.
  * @param array $options Options:
  *   - `default`: Default value to return if no value found in request
  *     data or context record.
  *   - `schemaDefault`: Boolean indicating whether default value from
  *      context's schema should be used if it's not explicitly provided.
  * @return mixed
  */
 public function val($field, $options = [])
 {
     $options += ['default' => null, 'schemaDefault' => true];
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     if ($options['default'] !== null || !$options['schemaDefault']) {
         return $options['default'];
     }
     if (empty($this->_context['defaults']) || !is_array($this->_context['defaults'])) {
         return null;
     }
     return Hash::get($this->_context['defaults'], $field);
 }
开发者ID:nrother,项目名称:cakephp,代码行数:30,代码来源:ArrayContext.php

示例10: 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

示例11: authenticate

 /**
  * Authenticate callback
  *
  * @param Request $request Cake request object.
  * @param Response $response Cake response object.
  * @return bool|mixed
  */
 public function authenticate(Request $request, Response $response)
 {
     $data = $request->session()->read(Configure::read('Users.Key.Session.social'));
     if (empty($data)) {
         return false;
     }
     $socialMail = Hash::get((array) $data->info, Configure::read('Users.Key.Data.email'));
     if (!empty($socialMail)) {
         $data->email = $socialMail;
         $data->validated = true;
     } else {
         $data->email = $request->data(Configure::read('Users.Key.Data.email'));
         $data->validated = false;
     }
     $user = $this->_findOrCreateUser($data);
     return $user;
 }
开发者ID:OrigamiStructures,项目名称:users,代码行数:24,代码来源:SocialAuthenticate.php

示例12: val

 /**
  * Get the value for a given path.
  *
  * Traverses the entity data and finds the value for $path.
  *
  * @param string $field The dot separated path to the value.
  * @return mixed The value of the field or null on a miss.
  */
 public function val($field)
 {
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     if (empty($this->_context['entity'])) {
         return null;
     }
     $parts = explode('.', $field);
     $entity = $this->_getEntity($parts);
     if (end($parts) === '_ids' && !empty($entity)) {
         return $this->_extractMultiple($entity, $parts);
     }
     if ($entity instanceof Entity) {
         return $entity->get(array_pop($parts));
     }
     return null;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:27,代码来源:EntityContext.php

示例13: val

 /**
  * Get the value for a given path.
  *
  * Traverses the entity data and finds the value for $path.
  *
  * @param string $field The dot separated path to the value.
  * @return mixed The value of the field or null on a miss.
  */
 public function val($field)
 {
     $val = $this->_request->data($field);
     if ($val !== null) {
         return $val;
     }
     if (empty($this->_context['entity'])) {
         return null;
     }
     $parts = explode('.', $field);
     $entity = $this->entity($parts);
     if (end($parts) === '_ids' && !empty($entity)) {
         return $this->_extractMultiple($entity, $parts);
     }
     if ($entity instanceof EntityInterface) {
         return $entity->get(array_pop($parts));
     } elseif (is_array($entity)) {
         $key = array_pop($parts);
         return isset($entity[$key]) ? $entity[$key] : null;
     }
     return null;
 }
开发者ID:aoliverio,项目名称:bookmarker-tutorial,代码行数:30,代码来源:EntityContext.php

示例14: _validateToken

 /**
  * Validate the request data against the cookie token.
  *
  * @param \Cake\Network\Request $request The request to validate against.
  * @throws \Cake\Network\Exception\InvalidCsrfTokenException when the CSRF token is invalid or missing.
  * @return void
  */
 protected function _validateToken(Request $request)
 {
     $cookie = $request->cookie($this->_config['cookieName']);
     $post = $request->data($this->_config['field']);
     $header = $request->header('X-CSRF-Token');
     if (empty($cookie)) {
         throw new InvalidCsrfTokenException(__d('cake', 'Missing CSRF token cookie'));
     }
     if ($post !== $cookie && $header !== $cookie) {
         throw new InvalidCsrfTokenException(__d('cake', 'CSRF token mismatch.'));
     }
 }
开发者ID:rlugojr,项目名称:cakephp,代码行数:19,代码来源:CsrfComponent.php

示例15: testDataWritingFalsey

 /**
  * Test writing falsey values.
  *
  * @return void
  */
 public function testDataWritingFalsey()
 {
     $request = new Request();
     $request->data('Post.null', null);
     $this->assertNull($request->data['Post']['null']);
     $request->data('Post.false', false);
     $this->assertFalse($request->data['Post']['false']);
     $request->data('Post.zero', 0);
     $this->assertSame(0, $request->data['Post']['zero']);
     $request->data('Post.empty', '');
     $this->assertSame('', $request->data['Post']['empty']);
 }
开发者ID:alexunique0519,项目名称:Blog_Cakephp_association,代码行数:17,代码来源:RequestTest.php


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