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


PHP Request::param方法代码示例

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


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

示例1: __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

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

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

示例4: _getNodeRef

 /**
  * Get node ref path by request.
  *
  * @return string
  */
 protected function _getNodeRef()
 {
     $ref = ['type' => 'controllers', 'plugin' => null, 'prefix' => Inflector::camelize($this->_request->param('prefix')), 'controller' => $this->_request->param('controller')];
     if ($this->_request->param('plugin') !== false) {
         $ref['plugin'] = FS::clean($this->_request->param('plugin'), '\\');
         return implode('/', $ref);
     }
     return FS::clean(implode('/', $ref), '/');
 }
开发者ID:UnionCMS,项目名称:Community,代码行数:14,代码来源:Permissions.php

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

示例6: xmlActionForm

 /**
  * Xml file path by request action.
  *
  * @param Request $request
  * @param bool $isAction
  * @return string
  */
 public static function xmlActionForm(Request $request, $isAction = false)
 {
     $plugin = $request->param('plugin');
     $controller = $request->param('controller');
     $prefix = $request->param('prefix');
     $action = $request->param('action');
     $tplPath = self::plugin($plugin) . 'src' . DS . 'Template';
     if ($prefix) {
         $tplPath .= DS . Inflector::camelize($prefix) . DS;
     }
     $tplPath .= $controller . DS . 'Forms' . DS;
     if (!$isAction) {
         $tplPath .= 'form.xml';
     }
     if ($isAction === true) {
         $tplPath .= $action . '.xml';
     }
     if (is_string($isAction)) {
         $tplPath .= $isAction . '.xml';
     }
     return $tplPath;
 }
开发者ID:Cheren,项目名称:union,代码行数:29,代码来源:Path.php

示例7: missingController

 /**
  * Throws an exception when a controller is missing.
  *
  * @param \Cake\Network\Request $request The request.
  * @throws \Cake\Routing\Exception\MissingControllerException
  * @return void
  */
 protected function missingController($request)
 {
     throw new MissingControllerException(['class' => $request->param('controller'), 'plugin' => $request->param('plugin'), 'prefix' => $request->param('prefix'), '_ext' => $request->param('_ext')]);
 }
开发者ID:markstory,项目名称:cakephp-spekkoek,代码行数:11,代码来源:ControllerFactory.php

示例8: testParamWriting

 /**
  * test writing request params with param()
  *
  * @return void
  */
 public function testParamWriting()
 {
     $request = new Request('/');
     $request->addParams(['action' => 'index']);
     $this->assertInstanceOf('Cake\\Network\\Request', $request->param('some', 'thing'), 'Method has not returned $this');
     $request->param('Post.null', null);
     $this->assertNull($request->params['Post']['null']);
     $request->param('Post.false', false);
     $this->assertFalse($request->params['Post']['false']);
     $request->param('Post.zero', 0);
     $this->assertSame(0, $request->params['Post']['zero']);
     $request->param('Post.empty', '');
     $this->assertSame('', $request->params['Post']['empty']);
     $this->assertSame('index', $request->action);
     $request->param('action', 'edit');
     $this->assertSame('edit', $request->action);
 }
开发者ID:alexunique0519,项目名称:Blog_Cakephp_association,代码行数:22,代码来源:RequestTest.php

示例9: _getProviderName

 /**
  * Get the provider name based on the request or on the provider set.
  *
  * @param \Cake\Network\Request $request Request object.
  * @return mixed Either false or an array of user information
  */
 protected function _getProviderName($request = null)
 {
     $provider = false;
     if (!is_null($this->_provider)) {
         $provider = SocialUtils::getProvider($this->_provider);
     } elseif (!empty($request)) {
         $provider = ucfirst($request->param('provider'));
     }
     return $provider;
 }
开发者ID:GF-TIC,项目名称:users,代码行数:16,代码来源:SocialAuthenticate.php

示例10: authorize

 /**
  * @param array $user Active user data
  * @param Request $request Request instance.
  * @return bool
  */
 public function authorize($user, Request $request)
 {
     $controller = $request->param('controller');
     $action = $request->param('action');
     return $this->validate($user, $controller, $action);
 }
开发者ID:styks1987,项目名称:cakephp-hier-auth,代码行数:11,代码来源:HierAuthorize.php

示例11: getParam

 /**
  * This method parses the provided rule param string and returns the appropriate value to be passed to the rule method.
  * @param string $ruleParam
  *          The rule param as parsed by the parseAuthAnnotation method.
  * @param array $pass
  *          The pass array from the parsed url.
  * @param Request $request
  *          The request object representing the current request.
  * @return mixed
  *          Returns the value corresponding to the provided $ruleParam.
  * @throws AnnAuthorizationException
  *          Throws this exception if the $pass or $request parameter designated by the $ruleParam does not exist.
  */
 protected function getParam($ruleParam, array $pass, Request $request)
 {
     $ruleMatched = preg_match('/(' . self::PARAM_TYPE_PASS . '|' . self::PARAM_TYPE_REQ . ')\\[([^\\]]+)\\]/', $ruleParam, $matches);
     if (!$ruleMatched) {
         return $ruleParam;
     }
     $type = $matches[1];
     $index = $matches[2];
     switch ($type) {
         case self::PARAM_TYPE_PASS:
             if (!array_key_exists($index, $pass)) {
                 throw new AnnAuthorizationException();
             }
             return $pass[$index];
         case self::PARAM_TYPE_REQ:
             if (!array_key_exists($index, $request->params)) {
                 throw new AnnAuthorizationException();
             }
             return $request->param($index);
     }
 }
开发者ID:michaelze,项目名称:cakephp-annauthorize,代码行数:34,代码来源:AnnAuthorization.php

示例12: testReadingParams

 /**
  * Test using param()
  *
  * @return void
  */
 public function testReadingParams()
 {
     $request = new Request();
     $request->addParams(array('controller' => 'posts', 'admin' => true, 'truthy' => 1, 'zero' => '0'));
     $this->assertFalse($request->param('not_set'));
     $this->assertTrue($request->param('admin'));
     $this->assertEquals(1, $request->param('truthy'));
     $this->assertEquals('posts', $request->param('controller'));
     $this->assertEquals('0', $request->param('zero'));
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:15,代码来源:RequestTest.php

示例13: provider

 /**
  * Returns the `$request`-ed provider.
  *
  * @param \Cake\Network\Request $request Current HTTP request.
  * @return \League\Oauth2\Client\Provider\GenericProvider|false
  */
 public function provider(Request $request)
 {
     if (!($alias = $request->param('provider'))) {
         return false;
     }
     if (empty($this->_provider)) {
         $this->_provider = $this->_getProvider($alias);
     }
     return $this->_provider;
 }
开发者ID:nielin,项目名称:OAuth2,代码行数:16,代码来源:OAuthAuthenticate.php

示例14: testAuthorizeRequestWithParams

 public function testAuthorizeRequestWithParams()
 {
     $this->assertTrue($this->AnnAuthorization->authorizeRequest(UsersTable::SUPERADMIN_ID, $this->controller, 'ruleWithParamAction', ['test1'], new Request()));
     $this->assertTrue($this->AnnAuthorization->authorizeRequest(UsersTable::SUPERADMIN_ID, $this->controller, 'ruleWithParamsAction', ['test1', 'test2'], new Request()));
     $request = new Request();
     $request->param('key1', 'test1');
     $request->param('key2', 'test2');
     $this->assertTrue($this->AnnAuthorization->authorizeRequest(UsersTable::SUPERADMIN_ID, $this->controller, 'ruleWithReqAction', ['test1', 'test2'], $request));
     $this->assertTrue($this->AnnAuthorization->authorizeRequest(UsersTable::SUPERADMIN_ID, $this->controller, 'ruleWithReqsAction', ['test1', 'test2'], $request));
     $this->assertTrue($this->AnnAuthorization->authorizeRequest(UsersTable::SUPERADMIN_ID, $this->controller, 'ruleWithMixedParamsAction', ['test1', 'test2'], $request));
 }
开发者ID:michaelze,项目名称:cakephp-annauthorize,代码行数:11,代码来源:AnnAuthorizationTest.php

示例15: getPerPage

 /**
  * Get the number per page.
  *
  * @return int
  */
 public function getPerPage()
 {
     return $this->request->param('paging.' . $this->pagingType . '.perPage');
 }
开发者ID:cakeplugins,项目名称:api,代码行数:9,代码来源:CakePaginatorAdapter.php


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