本文整理汇总了PHP中Nette\Application\Request::setPresenterName方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setPresenterName方法的具体用法?PHP Request::setPresenterName怎么用?PHP Request::setPresenterName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\Request
的用法示例。
在下文中一共展示了Request::setPresenterName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
});
}
示例2: 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';
});
}
示例3: constructUrl
/**
* @param \Nette\Application\Request $appRequest
* @param \Nette\Http\Url $refUrl
* @return string|null
*/
public function constructUrl(Request $appRequest, Url $refUrl)
{
$presenter = $appRequest->getPresenterName();
if (!Strings::startsWith($presenter, self::SUBMODULE_NAME . ':')) {
return null;
}
if (Strings::endsWith($presenter, ':' . self::DEFAULT_PRESENTER)) {
$presenter = substr($presenter, 0, -strlen(':' . self::DEFAULT_PRESENTER));
}
$appRequest->setPresenterName(substr($presenter, strlen(self::SUBMODULE_NAME . ':')));
return parent::constructUrl($appRequest, $refUrl);
}
示例4: 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';
});
}
示例5: setRequestParams
/**
* @param \Nette\Application\Request
* @param array
* @return \Nette\Application\Request
*/
private function setRequestParams(\Nette\Application\Request $appRequest, array $params)
{
$metadata = $this->getDefaults();
if (!isset($params[self::PRESENTER_KEY])) {
throw new \InvalidStateException('Missing presenter in route definition.');
}
if (isset($metadata[self::MODULE_KEY])) {
if (!isset($params[self::MODULE_KEY])) {
throw new \InvalidStateException('Missing module in route definition.');
}
$presenter = $params[self::MODULE_KEY] . ':' . $params[self::PRESENTER_KEY];
unset($params[self::MODULE_KEY], $params[self::PRESENTER_KEY]);
} else {
$presenter = $params[self::PRESENTER_KEY];
unset($params[self::PRESENTER_KEY]);
}
$appRequest->setPresenterName($presenter);
$appRequest->setParameters($params);
return $appRequest;
}
示例6: modifyConstructRequest
/**
* Modify request by page
*
* @param \Nette\Application\Request $request
* @param RouteEntity $route
* @param $parameters
* @param string $domain
* @return \Nette\Application\Request
*/
protected function modifyConstructRequest(Request $request, RouteEntity $route, $parameters, $domain)
{
$request->setPresenterName(self::DEFAULT_MODULE . ':' . self::DEFAULT_PRESENTER);
$request->setParameters(array('module' => self::DEFAULT_MODULE, 'presenter' => self::DEFAULT_PRESENTER, 'action' => self::DEFAULT_ACTION, 'lang' => count($this->languages) > 1 ? isset($parameters['lang']) ? $parameters['lang'] : ($route->page->language ? $route->page->language->alias : $this->defaultLanguage) : NULL, 'slug' => $route->getUrl(), 'domain' => $route->domain ? $route->domain->domain : '') + $parameters);
return $request;
}