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


PHP Request::getParams方法代码示例

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


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

示例1: createTemplate

 /**
  * Template factory
  * @param  string
  * @param  callback
  * @return Nette\Templating\ITemplate
  */
 public function createTemplate($class = NULL, $latteFactory = NULL)
 {
     $template = $class ? new $class() : new Nette\Templating\FileTemplate();
     $template->setParams($this->request->getParams());
     $template->presenter = $this;
     $template->context = $context = $this->context;
     $url = $context->httpRequest->getUrl();
     $template->baseUrl = rtrim($url->getBaseUrl(), '/');
     $template->basePath = rtrim($url->getBasePath(), '/');
     $template->registerHelperLoader('Nette\\Templating\\DefaultHelpers::loader');
     $template->setCacheStorage($context->templateCacheStorage);
     $template->onPrepareFilters[] = function ($template) use($latteFactory, $context) {
         $template->registerFilter($latteFactory ? $latteFactory() : new Nette\Latte\Engine());
     };
     return $template;
 }
开发者ID:kovkus,项目名称:r-cms,代码行数:22,代码来源:MicroPresenter.php

示例2: constructUrl

 /**
  * Constructs absolute URL from Request object.
  * @param  Nette\Application\Request
  * @param  Nette\Http\Url
  * @return string|NULL
  */
 public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
 {
     $params = $appRequest->getParams();
     // presenter name
     $presenter = $appRequest->getPresenterName();
     if (strncasecmp($presenter, $this->module, strlen($this->module)) === 0) {
         $params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module));
     } else {
         return NULL;
     }
     // remove default values; NULL values are retain
     foreach ($this->defaults as $key => $value) {
         if (isset($params[$key]) && $params[$key] == $value) {
             // intentionally ==
             unset($params[$key]);
         }
     }
     $url = ($this->flags & self::SECURED ? 'https://' : 'http://') . $refUrl->getAuthority() . $refUrl->getPath();
     $sep = ini_get('arg_separator.input');
     $query = http_build_query($params, '', $sep ? $sep[0] : '&');
     if ($query != '') {
         // intentionally ==
         $url .= '?' . $query;
     }
     return $url;
 }
开发者ID:kovkus,项目名称:r-cms,代码行数:32,代码来源:SimpleRouter.php

示例3: initGlobalParams

	/**
	 * Initializes $this->globalParams, $this->signal & $this->signalReceiver, $this->action, $this->view. Called by run().
	 * @return void
	 * @throws Nette\Application\BadRequestException if action name is not valid
	 */
	private function initGlobalParams()
	{
		// init $this->globalParams
		$this->globalParams = array();
		$selfParams = array();

		$params = $this->request->getParams();
		if ($this->isAjax()) {
			$params = $this->request->getPost() + $params;
		}

		foreach ($params as $key => $value) {
			$a = strlen($key) > 2 ? strrpos($key, self::NAME_SEPARATOR, -2) : FALSE;
			if ($a === FALSE) {
				$selfParams[$key] = $value;
			} else {
				$this->globalParams[substr($key, 0, $a)][substr($key, $a + 1)] = $value;
			}
		}

		// init & validate $this->action & $this->view
		$this->changeAction(isset($selfParams[self::ACTION_KEY]) ? $selfParams[self::ACTION_KEY] : self::DEFAULT_ACTION);

		// init $this->signalReceiver and key 'signal' in appropriate params array
		$this->signalReceiver = $this->getUniqueId();
		if (!empty($selfParams[self::SIGNAL_KEY])) {
			$param = $selfParams[self::SIGNAL_KEY];
			$pos = strrpos($param, '-');
			if ($pos) {
				$this->signalReceiver = substr($param, 0, $pos);
				$this->signal = substr($param, $pos + 1);
			} else {
				$this->signalReceiver = $this->getUniqueId();
				$this->signal = $param;
			}
			if ($this->signal == NULL) { // intentionally ==
				$this->signal = NULL;
			}
		}

		$this->loadState($selfParams);
	}
开发者ID:norbe,项目名称:nette,代码行数:47,代码来源:Presenter.php

示例4: constructUrl

 /**
  * Constructs absolute URL from Request object.
  * @param  Nette\Application\Request
  * @param  Nette\Http\Url
  * @return string|NULL
  */
 public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
 {
     if ($this->flags & self::ONE_WAY) {
         return NULL;
     }
     $params = $appRequest->getParams();
     $metadata = $this->metadata;
     $presenter = $appRequest->getPresenterName();
     $params[self::PRESENTER_KEY] = $presenter;
     if (isset($metadata[self::MODULE_KEY])) {
         // try split into module and [submodule:]presenter parts
         $module = $metadata[self::MODULE_KEY];
         if (isset($module['fixity']) && strncasecmp($presenter, $module[self::VALUE] . ':', strlen($module[self::VALUE]) + 1) === 0) {
             $a = strlen($module[self::VALUE]);
         } else {
             $a = strrpos($presenter, ':');
         }
         if ($a === FALSE) {
             $params[self::MODULE_KEY] = '';
         } else {
             $params[self::MODULE_KEY] = substr($presenter, 0, $a);
             $params[self::PRESENTER_KEY] = substr($presenter, $a + 1);
         }
     }
     foreach ($metadata as $name => $meta) {
         if (!isset($params[$name])) {
             continue;
             // retains NULL values
         }
         if (isset($meta['fixity'])) {
             if (is_scalar($params[$name]) && strcasecmp($params[$name], $meta[self::VALUE]) === 0) {
                 // remove default values; NULL values are retain
                 unset($params[$name]);
                 continue;
             } elseif ($meta['fixity'] === self::CONSTANT) {
                 return NULL;
                 // missing or wrong parameter '$name'
             }
         }
         if (!is_scalar($params[$name])) {
         } elseif (isset($meta['filterTable2'][$params[$name]])) {
             $params[$name] = $meta['filterTable2'][$params[$name]];
         } elseif (isset($meta[self::FILTER_OUT])) {
             $params[$name] = call_user_func($meta[self::FILTER_OUT], $params[$name]);
         }
         if (isset($meta[self::PATTERN]) && !preg_match($meta[self::PATTERN], rawurldecode($params[$name]))) {
             return NULL;
             // pattern not match
         }
     }
     // compositing path
     $sequence = $this->sequence;
     $brackets = array();
     $required = 0;
     $url = '';
     $i = count($sequence) - 1;
     do {
         $url = $sequence[$i] . $url;
         if ($i === 0) {
             break;
         }
         $i--;
         $name = $sequence[$i];
         $i--;
         // parameter name
         if ($name === ']') {
             // opening optional part
             $brackets[] = $url;
         } elseif ($name[0] === '[') {
             // closing optional part
             $tmp = array_pop($brackets);
             if ($required < count($brackets) + 1) {
                 // is this level optional?
                 if ($name !== '[!') {
                     // and not "required"-optional
                     $url = $tmp;
                 }
             } else {
                 $required = count($brackets);
             }
         } elseif ($name[0] === '?') {
             // "foo" parameter
             continue;
         } elseif (isset($params[$name]) && $params[$name] != '') {
             // intentionally ==
             $required = count($brackets);
             // make this level required
             $url = $params[$name] . $url;
             unset($params[$name]);
         } elseif (isset($metadata[$name]['fixity'])) {
             // has default value?
             $url = $metadata[$name]['defOut'] . $url;
         } else {
             return NULL;
//.........这里部分代码省略.........
开发者ID:rostenkowski,项目名称:HttpPHPUnit,代码行数:101,代码来源:Route.php


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