本文整理汇总了PHP中Nette\Application\Request::getParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getParameter方法的具体用法?PHP Request::getParameter怎么用?PHP Request::getParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\Request
的用法示例。
在下文中一共展示了Request::getParameter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: routeMatched
/**
* Event thatis firex when particular ApiRoute is matched
* @param ApiRoute $route
* @param Request $request
* @return void
*/
public function routeMatched(ApiRoute $route, Request $request)
{
if (NULL !== ($format = $request->getParameter(self::API_DOCU_STARTER_QUERY_KEY_GENERATE))) {
$this->generator->generateAll($this->router);
exit(0);
}
if (NULL !== ($format = $request->getParameter(self::API_DOCU_STARTER_QUERY_KEY_TARGET))) {
$this->generator->generateTarget($route, $request);
exit(0);
}
}
示例2: run
public function run(Nette\Application\Request $request)
{
$exception = $request->getParameter('exception');
if ($exception instanceof Nette\Application\BadRequestException) {
return new Responses\ForwardResponse($request->setPresenterName('Error4xx'));
}
$this->logger->log($exception, ILogger::EXCEPTION);
return new Responses\CallbackResponse(function () {
require __DIR__ . '/templates/Error/500.phtml';
});
}
示例3: run
/**
* @return Nette\Application\IResponse
*/
public function run(Nette\Application\Request $request)
{
$e = $request->getParameter('exception');
if ($e instanceof Nette\Application\BadRequestException) {
// $this->logger->log("HTTP code {$e->getCode()}: {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", 'access');
return new Nette\Application\Responses\ForwardResponse($request->setPresenterName('Error4xx'));
}
$this->logger->log($e, ILogger::EXCEPTION);
return new Nette\Application\Responses\CallbackResponse(function () {
require __DIR__ . '/templates/Error/500.phtml';
});
}
示例4: constructUrl
public function constructUrl(Application\Request $request, Http\Url $url)
{
if ($request->getPresenterName() !== 'Nette:Micro') {
return;
}
// parameter "id" will be name in string or instance of ImageInfo
$id = $request->getParameter('id');
if ($id instanceof Imager\ImageInfo) {
$id = $id->getFilename();
}
$parts = explode('.', $id);
// extension is on last position
$extension = '.' . array_pop($parts);
// implode back for case that name contains dots
$name = implode('.', $parts);
$width = $request->getParameter('width');
$height = $request->getParameter('height');
$quality = $request->getParameter('quality');
$dimension = Imager\Helpers::createDimensionName($width, $height, $quality);
return $this->basePath . Imager\Helpers::getSubPath($id) . $name . $dimension . $extension;
}
示例5: run
/**
* This method is usually implemented by the more complex UI\Presenter
* But since an unhandled exception might have occurred,
* it should be processed as simply as possible to avoid any further problems or even another exception.
*
* @param Nette\Application\Request $request
* @return Responses\CallbackResponse|Responses\ForwardResponse
*/
public function run(Nette\Application\Request $request)
{
$exception = $request->getParameter('exception');
// if it's a simple BadRequestException, use the more powerful presenter
if ($exception instanceof Nette\Application\BadRequestException) {
return new Responses\ForwardResponse($request->setPresenterName('Error4xx'));
}
$this->logger->log($exception, ILogger::EXCEPTION);
// the 500 means unhandled exception, which should translate to the simplest page possible
return new Responses\CallbackResponse(function () {
require __DIR__ . '/templates/Error/500.phtml';
});
}
示例6: run
/**
* @return Application\IResponse
*/
public function run(Application\Request $request)
{
$e = $request->getParameter('exception');
if ($e instanceof Application\BadRequestException) {
$code = $e->getCode();
} else {
$code = 500;
if ($this->logger) {
$this->logger->log($e, ILogger::EXCEPTION);
}
}
return new Application\Responses\CallbackResponse(function () use($code) {
require __DIR__ . '/templates/error.phtml';
});
}
示例7: run
/**
* @param Request $request
* @return IResponse
*/
public function run(Request $request)
{
$e = $request->getParameter('exception');
if ($e instanceof BadRequestException) {
$code = $e->getCode();
} else {
$code = 500;
if ($this->logger) {
try {
$this->logger->log($e, ILogger::EXCEPTION);
} catch (\Exception $e) {
// logger may fail as well
}
}
}
if (isset(JsonResponse::$messages[$code])) {
$message = JsonResponse::$messages[$code];
} else {
$message = 'Unknown error';
}
return $this->createResponse($message, $code);
}
示例8: createFromRequest
/**
* @param Request $request
* @return PaymentResult
*/
public static function createFromRequest(Request $request)
{
$paymentResult = new PaymentResult();
$paymentResult->setAuthResult($request->getParameter('authResult'));
$paymentResult->setPspReference($request->getParameter('pspReference'));
$paymentResult->setMerchantReference($request->getParameter('merchantReference'));
$paymentResult->setSkinCode($request->getParameter('skinCode'));
$paymentResult->setMerchantReturnData($request->getParameter('merchantReturnData'));
$paymentResult->setShopperLocale($request->getParameter('shopperLocale'));
$paymentResult->setPaymentMethod($request->getParameter('paymentMethod'));
return $paymentResult;
}
示例9: constructUrl
/**
* @param Request $appRequest
* @param Url $refUrl
* @return null|string
*/
public function constructUrl(Request $appRequest, Url $refUrl)
{
// one way can't generate link
if ($this->options['oneWay']) {
return NULL;
}
$params = $this->clearParameters($appRequest->getParameters());
$action = new Action($appRequest->getPresenterName() . ':' . $appRequest->getParameter('action'), $params);
// ISource return NULL, not found url to generate
if (($seoUrl = $this->source->toUrl($action)) === NULL) {
return NULL;
}
if (!$seoUrl instanceof Url) {
$seoUrl = new Url($seoUrl);
}
// host
if ($seoUrl->getHost()) {
$host = $refUrl->getHost();
$parts = ip2long($host) ? [$host] : array_reverse(explode('.', $host));
$host = strtr($seoUrl->getHost(), ['%tld%' => $parts[0], '%domain%' => isset($parts[1]) ? "{$parts['1']}.{$parts['0']}" : $parts[0], '%sld%' => isset($parts[1]) ? $parts[1] : '', '%host%' => $refUrl->getHost()]);
} else {
$host = $refUrl->getHost();
}
// path
$path = $seoUrl->getPath();
// query
$query = $seoUrl->getQueryParameters() + $params;
ksort($query);
$seoUrl->setQuery($query);
$query = $seoUrl->getQuery();
// fragment
$fragment = $seoUrl->getFragment();
return ($this->options['secured'] ? 'https' : 'http') . '://' . $host . $refUrl->getBasePath() . ($path === '/' ? '' : $path) . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : '');
}
示例10: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\Url $refUrl)
{
$this->loadLocales();
$appPath = $appRequest->getPresenterName() . ':' . $appRequest->getParameter('action') . ':' . $appRequest->getParameter('internal_id');
/** @var Url $urlEntity */
$cachedResult = $this->cache->load($appPath, function (&$dependencies) use($appRequest) {
$presenter = $appRequest->getPresenterName();
$action = $appRequest->getParameter('action');
$internal_id = $appRequest->getParameter('internal_id');
$fallback = false;
if (isset($internal_id)) {
/** @var Url $url */
$urlEntity = $this->getUrlEntity($presenter, $action, $internal_id);
if ($urlEntity === null) {
$fallback = true;
$urlEntity = $this->getUrlEntity($presenter, $action);
}
} else {
$urlEntity = $this->getUrlEntity($presenter, $action);
}
if ($urlEntity === null) {
$this->logger->addWarning(sprintf('No route found
| presenter: %s
| action: %s
| id %s', $presenter, $action, $internal_id));
return null;
}
$dependencies = [Nette\Caching\Cache::TAGS => $urlEntity->getCacheKey()];
return [$urlEntity, $fallback];
});
$urlEntity = $cachedResult[0];
$fallback = $cachedResult[1];
if ($urlEntity === null) {
return null;
}
$baseUrl = 'http://' . $refUrl->getAuthority() . $refUrl->getBasePath();
if ($urlEntity->getActualUrlToRedirect() === null) {
$path = $urlEntity->getUrlPath();
} else {
$path = $urlEntity->getActualUrlToRedirect()->getUrlPath();
}
$params = $appRequest->getParameters();
unset($params['action']);
if ($fallback === false) {
unset($params['internal_id']);
}
$defaultLocale = array_search(true, $this->locales);
$locale = isset($params['locale']) ? $params['locale'] : $defaultLocale;
unset($params['locale']);
if ($defaultLocale === $locale) {
$locale = '';
} else {
$locale .= '/';
}
$resultUrl = $baseUrl . $locale . Nette\Utils\Strings::webalize($path, '/.');
$this->urlParametersConverter->out($urlEntity, $params);
// todo
$q = http_build_query($params, null, '&');
if ($q != '') {
$resultUrl .= '?' . $q;
}
return $resultUrl;
}
示例11: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(Request $request, Nette\Http\Url $url)
{
if ($this->presenter != $request->getPresenterName()) {
return NULL;
}
$base_url = $url->getBaseUrl();
$action = $request->getParameter('action');
$parameters = $request->getParameters();
unset($parameters['action']);
$path = ltrim($this->getPath(), '/');
if (FALSE === array_search($action, $this->actions)) {
return NULL;
}
foreach ($parameters as $name => $value) {
if (strpos($path, "<{$name}>") !== FALSE && $value !== NULL) {
$path = str_replace("<{$name}>", $value, $path);
unset($parameters[$name]);
}
}
$path = preg_replace_callback('/\\[.+?\\]/', function ($item) {
if (strpos(end($item), '<')) {
return '';
}
return end($item);
}, $path);
/**
* There are still some required parameters in url mask
*/
if (preg_match('/<\\w+>/', $path)) {
return NULL;
}
$path = str_replace(['[', ']'], '', $path);
$query = http_build_query($parameters);
return $base_url . $path . ($query ? '?' . $query : '');
}