本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
//.........这里部分代码省略.........