本文整理汇总了PHP中Nette\Application\Request::getPresenterName方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getPresenterName方法的具体用法?PHP Request::getPresenterName怎么用?PHP Request::getPresenterName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\Request
的用法示例。
在下文中一共展示了Request::getPresenterName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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'] : ''));
}
}
示例3: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->cachedRoutes === NULL) {
$this->warmupCache();
}
if ($this->module) {
if (strncmp($tmp = $appRequest->getPresenterName(), $this->module, strlen($this->module)) === 0) {
$appRequest = clone $appRequest;
$appRequest->setPresenterName(substr($tmp, strlen($this->module)));
} else {
return NULL;
}
}
$presenter = $appRequest->getPresenterName();
if (!isset($this->cachedRoutes[$presenter])) {
$presenter = '*';
}
foreach ($this->cachedRoutes[$presenter] as $route) {
$url = $route->constructUrl($appRequest, $refUrl);
if ($url !== NULL) {
return $url;
}
}
return NULL;
}
示例4: 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;
}
示例5: __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();
}
示例6: getAction
/**
* @return string
*/
public function getAction($fullyQualified = false)
{
if ($this->action === null) {
$method = $this->request->getMethod();
$this->action = isset(self::$actionMap[$method]) ? self::$actionMap[$method] : strtolower($method);
}
return $fullyQualified ? "{$this->request->getPresenterName()}:{$this->action}" : $this->action;
}
示例7: 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);
}
}
}
示例8: run
public function run(Nette\Application\Request $request)
{
$exception = $request->getParameter('exception');
if ($exception instanceof Nette\Application\BadRequestException) {
list($module, , $sep) = Nette\Application\Helpers::splitName($request->getPresenterName());
return new Responses\ForwardResponse($request->setPresenterName($module . $sep . 'Error4xx'));
}
$this->logger->log($exception, ILogger::EXCEPTION);
return new Responses\CallbackResponse(function () {
require __DIR__ . '/templates/Error/500.phtml';
});
}
示例9: 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);
}
示例10: 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);
}
示例11: 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'] : ''));
}
示例12: 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');
list($module, , $sep) = Nette\Application\Helpers::splitName($request->getPresenterName());
return new Responses\ForwardResponse($request->setPresenterName($module . $sep . 'Error4xx'));
}
$this->logger->log($e, ILogger::EXCEPTION);
return new Responses\CallbackResponse(function () {
require __DIR__ . '/templates/Error/500.phtml';
});
}
示例13: 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'] : ''));
}
示例14: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->cachedRoutes === NULL) {
$routes = array();
$routes['*'] = array();
foreach ($this as $route) {
$presenter = $route instanceof Route ? $route->getTargetPresenter() : NULL;
if ($presenter === FALSE) {
continue;
}
if (is_string($presenter)) {
$presenter = strtolower($presenter);
if (!isset($routes[$presenter])) {
$routes[$presenter] = $routes['*'];
}
$routes[$presenter][] = $route;
} else {
foreach ($routes as $id => $foo) {
$routes[$id][] = $route;
}
}
}
$this->cachedRoutes = $routes;
}
if ($this->module) {
if (strncasecmp($tmp = $appRequest->getPresenterName(), $this->module, strlen($this->module)) === 0) {
$appRequest = clone $appRequest;
$appRequest->setPresenterName(substr($tmp, strlen($this->module)));
} else {
return NULL;
}
}
$presenter = strtolower($appRequest->getPresenterName());
if (!isset($this->cachedRoutes[$presenter])) {
$presenter = '*';
}
foreach ($this->cachedRoutes[$presenter] as $route) {
$url = $route->constructUrl($appRequest, $refUrl);
if ($url !== NULL) {
return $url;
}
}
return NULL;
}
示例15: constructUrl
/**
* Constructs absolute URL from Request object.
* @param Nette\Application\Request
* @param Nette\Http\Url
* @return string|NULL
*/
public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\Url $refUrl)
{
$presenterName = $appRequest->getPresenterName();
$presenterClass = $this->formatPresenterClass($presenterName);
if (in_array('Tatami\\Presenters\\IFrontendModulePresenter', class_implements($presenterClass))) {
$router = $this->frontRouter;
} else {
$router = $this->adminRouter;
}
if ($this->cachedRoutes === NULL) {
$routes = array();
$routes['*'] = array();
foreach ($router as $route) {
$presenter = $route instanceof Route ? $route->getTargetPresenter() : NULL;
if ($presenter === FALSE) {
continue;
}
if (is_string($presenter)) {
$presenter = strtolower($presenter);
if (!isset($routes[$presenter])) {
$routes[$presenter] = $routes['*'];
}
$routes[$presenter][] = $route;
} else {
foreach ($routes as $id => $foo) {
$routes[$id][] = $route;
}
}
}
$this->cachedRoutes = $routes;
}
$presenter = strtolower($appRequest->getPresenterName());
if (!isset($this->cachedRoutes[$presenter])) {
$presenter = '*';
}
foreach ($this->cachedRoutes[$presenter] as $route) {
$url = $route->constructUrl($appRequest, $refUrl);
if ($url !== NULL) {
return $url;
}
}
return NULL;
}