本文整理汇总了PHP中Nette\Application\Request::getParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getParameters方法的具体用法?PHP Request::getParameters怎么用?PHP Request::getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\Request
的用法示例。
在下文中一共展示了Request::getParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolve
/**
* @param \Kdyby\Translation\Translator $translator
* @return string|NULL
*/
public function resolve(Kdyby\Translation\Translator $translator)
{
if ($this->request === NULL) {
return NULL;
}
$params = $this->request->getParameters();
return !empty($params['locale']) ? $params['locale'] : NULL;
}
示例2: __invoke
/**
* @param \Nette\Application\Application $application
* @param \Nette\Application\Request $request
*/
public function __invoke(Application $application, Request $request)
{
if (PHP_SAPI === 'cli') {
newrelic_background_job(TRUE);
}
$params = $request->getParameters();
$action = $request->getPresenterName();
if (isset($params[$this->actionKey])) {
$action = sprintf('%s:%s', $action, $params[$this->actionKey]);
}
if (!empty($this->map)) {
foreach ($this->map as $pattern => $appName) {
if ($pattern === '*') {
continue;
}
if (Strings::endsWith($pattern, '*')) {
$pattern = Strings::substring($pattern, 0, -1);
}
if (Strings::startsWith($pattern, ':')) {
$pattern = Strings::substring($pattern, 1);
}
if (Strings::startsWith($action, $pattern)) {
\VrtakCZ\NewRelic\Tracy\Bootstrap::setup($appName, $this->license);
break;
}
}
}
newrelic_name_transaction($action);
newrelic_disable_autorum();
}
示例3: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->flags & self::ONE_WAY) {
return NULL;
}
$params = $appRequest->getParameters();
// presenter name
$presenter = $appRequest->getPresenterName();
if (strncmp($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;
}
示例4: constructUrl
public function constructUrl(Request $appRequest, Url $refUrl)
{
// Module prefix not match.
if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
return null;
}
$params = $appRequest->getParameters();
$urlStack = [];
// Module prefix
$moduleFrags = explode(":", Strings::lower($appRequest->getPresenterName()));
$resourceName = array_pop($moduleFrags);
$urlStack += $moduleFrags;
// Resource
$urlStack[] = Strings::lower($resourceName);
// Id
if (isset($params['id']) && is_scalar($params['id'])) {
$urlStack[] = $params['id'];
unset($params['id']);
}
// Set custom action
if (isset($params['action']) && $this->_isApiAction($params['action'])) {
unset($params['action']);
}
$url = $refUrl->getBaseUrl() . implode('/', $urlStack);
// Add query parameters
if (!empty($params)) {
$url .= "?" . http_build_query($params);
}
return $url;
}
示例5: createTemplate
/**
* Template factory.
* @param string
* @param callable
* @return Nette\Templating\ITemplate
*/
public function createTemplate($class = NULL, $latteFactory = NULL)
{
$template = $class ? new $class() : new Nette\Templating\FileTemplate();
$template->setParameters($this->request->getParameters());
$template->presenter = $this;
$template->context = $context = $this->context;
$url = $context->getByType('Nette\\Http\\IRequest')->getUrl();
$template->baseUrl = rtrim($url->getBaseUrl(), '/');
$template->basePath = rtrim($url->getBasePath(), '/');
$template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
$template->setCacheStorage($context->getService('nette.templateCacheStorage'));
$template->onPrepareFilters[] = function ($template) use($latteFactory) {
$template->registerFilter($latteFactory ? $latteFactory() : new Nette\Latte\Engine());
};
return $template;
}
示例6: getSignal
/**
* @param \Ark8\Security\Authorizators\Request $request
* @return array
* @throws \Nette\InvalidStateException
*/
private function getSignal(Request $request)
{
$params = $request->getParameters();
if ($this->httpRequest->isAjax()) {
$params += $request->getPost();
} elseif (($tmp = $request->getPost(Presenter::SIGNAL_KEY)) !== NULL) {
$params[self::SIGNAL_KEY] = $tmp;
}
$signal = NULL;
$signalReceiver = '';
if (isset($params[Presenter::SIGNAL_KEY])) {
$param = $params[Presenter::SIGNAL_KEY];
$pos = strrpos($param, '-');
if ($pos) {
$signalReceiver = substr($param, 0, $pos);
$signal = substr($param, $pos + 1);
} else {
$signalReceiver = $this->getUniqueId();
$signal = $param;
}
if ($signal == NULL) {
// intentionally ==
$signal = NULL;
}
}
return [$signal, explode('-', $signalReceiver)];
}
示例7: constructUrl
/**
* @param Application\Request $appRequest
* @param Nette\Http\Url $refUrl
* @return NULL|string
*/
public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
{
$parameters = $appRequest->getParameters();
if (isset($parameters['action']) && $parameters['action'] == FALSE) {
$parameters['action'] = NULL;
}
$appRequest->setParameters($parameters);
return parent::constructUrl($appRequest, $refUrl);
}
示例8: handleApplicationRequest
public function handleApplicationRequest(Application\Application $application, Application\Request $request)
{
if ($request->getPresenterName() === 'Kdyby:Cli') {
$parameters = $request->getParameters();
if (isset($parameters['output']) && ($output = $parameters['output']) instanceof OutputInterface) {
$this->outputWriter->setOutputInterface($output);
}
}
}
示例9: canonicalize
/**
* Conditional redirect to canonicalized URI.
*
* @return void
* @throws Nette\Application\AbortException
*/
public function canonicalize()
{
if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) {
try {
$url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->getParameters(), 'redirectX');
} catch (InvalidLinkException $e) {
}
if (isset($url) && !$this->getHttpRequest()->getUrl()->isEqual($url)) {
$this->sendResponse(new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY));
}
}
}
示例10: onRequest
public function onRequest(Application $app, Request $request)
{
if (!extension_loaded('newrelic')) {
return;
}
if (PHP_SAPI === 'cli') {
newrelic_name_transaction('$ ' . basename($_SERVER['argv'][0]) . ' ' . implode(' ', array_slice($_SERVER['argv'], 1)));
newrelic_background_job(TRUE);
return;
}
$params = $request->getParameters();
newrelic_name_transaction($request->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : ''));
}
示例11: constructUrl
/**
* Constructs absolute URL from Request object
*
* @param \Nette\Application\Request $appRequest
* @param \Nette\Http\Url $refUrl
* @return string|NULL
*/
public function constructUrl(Application\Request $appRequest, \Nette\Http\Url $refUrl)
{
if ($appRequest->getPresenterName() != $this->getTargetPresenter()) {
return NULL;
}
$params = $appRequest->getParameters();
if (!isset($params['id']) && isset($params[0])) {
$params['id'] = $params[0];
unset($params[0]);
$appRequest->setParameters($params);
}
return parent::constructUrl($appRequest, $refUrl);
}
示例12: createTemplate
/**
* Template factory.
* @param string
* @return Application\UI\ITemplate
*/
public function createTemplate($class = NULL, callable $latteFactory = NULL)
{
$latte = $latteFactory ? $latteFactory() : $this->getContext()->getByType(Nette\Bridges\ApplicationLatte\ILatteFactory::class)->create();
$template = $class ? new $class() : new Nette\Bridges\ApplicationLatte\Template($latte);
$template->setParameters($this->request->getParameters());
$template->presenter = $this;
$template->context = $this->context;
if ($this->httpRequest) {
$url = $this->httpRequest->getUrl();
$template->baseUrl = rtrim($url->getBaseUrl(), '/');
$template->basePath = rtrim($url->getBasePath(), '/');
}
return $template;
}
示例13: onRequest
/**
* @param Nette\Application\Application $app
* @param Nette\Application\Request $request
*/
public function onRequest(Nette\Application\Application $app, Nette\Application\Request $request)
{
if (Consumerr::isConsole()) {
Consumerr::setBackgroundJob(TRUE);
Consumerr::setName('$ ' . basename($_SERVER['argv'][0]) . ' ' . implode(' ', array_slice($_SERVER['argv'], 1)));
} else {
$params = $request->getParameters();
if ($request->method === 'FORWARD' && $request->getPresenterName() === $app->errorPresenter) {
return;
//do not replace presenter name with error presenter
}
Consumerr::setName($request->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : ''));
}
}
示例14: initGlobalParameters
/**
* 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 initGlobalParameters()
{
// init $this->globalParams
$this->globalParams = array();
$selfParams = array();
$params = $this->request->getParameters();
if ($this->isAjax()) {
$params += $this->request->getPost();
}
if (isset($this->request->post[self::SIGNAL_KEY])) {
$params[self::SIGNAL_KEY] = $this->request->post[self::SIGNAL_KEY];
}
foreach ($params as $key => $value) {
if (!preg_match('#^((?:[a-z0-9_]+-)*)((?!\d+\z)[a-z0-9_]+)\z#i', $key, $matches)) {
continue;
} elseif (!$matches[1]) {
$selfParams[$key] = $value;
} else {
$this->globalParams[substr($matches[1], 0, -1)][$matches[2]] = $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 (isset($selfParams[self::SIGNAL_KEY])) {
$param = $selfParams[self::SIGNAL_KEY];
if (!is_string($param)) {
$this->error('Signal name is not string.');
}
$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);
}
示例15: onRequest
public function onRequest(Application $app, Request $request)
{
if (!extension_loaded('newrelic')) {
return;
}
if (PHP_SAPI === 'cli') {
// uložit v čitelném formátu
newrelic_name_transaction('$ ' . basename($_SERVER['argv'][0]) . ' ' . implode(' ', array_slice($_SERVER['argv'], 1)));
// označit jako proces na pozadí
newrelic_background_job(TRUE);
return;
}
// pojmenování požadavku podle presenteru a akce
$params = $request->getParameters();
newrelic_name_transaction($_SERVER['HTTP_HOST'] . " | " . $request->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : ''));
}