• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Network\Request类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Request类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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' => '[email protected]', '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


示例16: testBeforeDispatch

 /**
  * testBeforeDispatch
  *
  * @return void
  */
 public function testBeforeDispatch()
 {
     Configure::write('App.namespace', 'TestApp');
     $filter = new ControllerFactoryFilter();
     $request = new Request();
     $response = new Response();
     $request->addParams(['prefix' => 'admin', 'controller' => 'Posts', 'action' => 'index']);
     $event = new Event(__CLASS__, $this, compact('request', 'response'));
     $filter->beforeDispatch($event);
     $this->assertEquals('TestApp\\Controller\\Admin\\PostsController', get_class($event->data['controller']));
     $request->addParams(['prefix' => 'admin/sub', 'controller' => 'Posts', 'action' => 'index']);
     $event = new Event(__CLASS__, $this, compact('request', 'response'));
     $filter->beforeDispatch($event);
     $this->assertEquals('TestApp\\Controller\\Admin\\Sub\\PostsController', get_class($event->data['controller']));
 }
开发者ID:jdaosavanh,项目名称:clickerwebapp,代码行数:20,代码来源:ControllerFactoryFilterTest.php


示例17: prefers

 /**
  * Determines which content-types the client prefers. If no parameters are given,
  * the single content-type that the client most likely prefers is returned. If $type is
  * an array, the first item in the array that the client accepts is returned.
  * Preference is determined primarily by the file extension parsed by the Router
  * if provided, and secondarily by the list of content-types provided in
  * HTTP_ACCEPT.
  *
  * @param string|array $type An optional array of 'friendly' content-type names, i.e.
  *   'html', 'xml', 'js', etc.
  * @return mixed If $type is null or not provided, the first content-type in the
  *    list, based on preference, is returned. If a single type is provided
  *    a boolean will be returned if that type is preferred.
  *    If an array of types are provided then the first preferred type is returned.
  *    If no type is provided the first preferred type is returned.
  * @see RequestHandlerComponent::setContent()
  */
 public function prefers($type = null)
 {
     $acceptRaw = $this->request->parseAccept();
     if (empty($acceptRaw)) {
         return $this->ext;
     }
     $accepts = $this->response->mapType(array_shift($acceptRaw));
     if (!$type) {
         if (empty($this->ext) && !empty($accepts)) {
             return $accepts[0];
         }
         return $this->ext;
     }
     $types = (array) $type;
     if (count($types) === 1) {
         if (!empty($this->ext)) {
             return in_array($this->ext, $types);
         }
         return in_array($types[0], $accepts);
     }
     $intersect = array_values(array_intersect($accepts, $types));
     if (empty($intersect)) {
         return false;
     }
     return $intersect[0];
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:43,代码来源:RequestHandlerComponent.php


示例18: testParamsRedirect

 public function testParamsRedirect()
 {
     $request = new Request(['url' => 'controller_posts/index', 'action' => 'index', '_method' => 'POST']);
     $request->env('REQUEST_METHOD', 'POST');
     $request->action = 'index';
     $request->data['Filter'] = ['Posts' => ['title' => 'foo', 'body' => 'bar', 'multi' => [1, 2]]];
     $controller = new Controller($request);
     $controller->listFilters = ['index' => ['fields' => ['Posts.title' => ['searchType' => 'wildcard', 'options' => []], 'Posts.body' => ['searchType' => 'wildcard'], 'Posts.multi' => ['searchType' => 'multipleselect', 'options' => [1 => 'one', 2 => 'two']]]]];
     $ListFilter = new ListFilterComponent($controller->components(), []);
     $event = new Event('Controller.startup', $controller);
     $ListFilter->startup($event);
     $this->assertEquals(array_keys($controller->listFilters['index']['fields']), array_keys($ListFilter->getFilters()['fields']));
     // Check if the request is being redirected properly
     $redirectUrl = parse_url($controller->response->header()['Location']);
     $this->assertEquals(urldecode($redirectUrl['query']), 'Filter-Posts-title=foo&Filter-Posts-body=bar&Filter-Posts-multi[0]=1&Filter-Posts-multi[1]=2');
 }
开发者ID:codekanzlei,项目名称:cake-list-filter,代码行数:16,代码来源:ListFilterComponentTest.php


示例19: _getUser

 /**
  * Retrieves or creates a user based on header data
  *
  * @param \Cake\Network\Request $request Request object.
  * @return mixed Either false or an array of user information
  */
 protected function _getUser(Request $request)
 {
     $config = $this->_config;
     $username = $request->header($config['headers']['username']);
     $result = $this->_query($username)->first();
     if (!empty($result)) {
         return $result;
     }
     $data = [$config['fields']['username'] => $username, $config['fields']['password'] => '', $config['fields']['name'] => $request->header($config['headers']['name']), $config['fields']['email'] => $request->header($config['headers']['email'])];
     $table = TableRegistry::get($config['userModel']);
     $result = $table->newEntity($data);
     if (!$table->save($result)) {
         return false;
     }
     return $result;
 }
开发者ID:josegonzalez,项目名称:media-manager,代码行数:22,代码来源:HeaderAuthenticate.php


示例20: unauthenticated

 /**
  * Handle unauthenticated access attempt. In implementation valid return values
  * can be:
  *
  * - Null - No action taken, AuthComponent should return appropriate response.
  * - Cake\Network\Response - A response object, which will cause AuthComponent to
  *   simply return that response.
  *
  * @param \Cake\Network\Request $request A request object.
  * @param \Cake\Network\Response $response A response object.
  * @return \Cake\Network\Response|bool
  */
 public function unauthenticated(Request $request, Response $response)
 {
     $response->type('json');
     $deviceId = $request->header($this->config('headerDeviceId'));
     $token = $request->header($this->config('headerToken'));
     if ($deviceId == null || $token == null) {
         return $this->unauthorizedResponse($response);
     }
     $generatedToken = $this->generateToken($deviceId);
     //Log::debug("CREATED TOKEN: ".$generatedToken);
     //Log::debug("SENT TOKEN: ".$token);
     if ($token != $generatedToken) {
         return $this->unauthorizedResponse($response);
     }
     return true;
 }
开发者ID:diegoRodriguezAguila,项目名称:Elfec.Helpdesk.MiniApi,代码行数:28,代码来源:HelpdeskTokenAuthenticate.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Network\Response类代码示例发布时间:2022-05-23
下一篇:
PHP Mailer\Email类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap