本文整理汇总了PHP中IContextSource::setRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP IContextSource::setRequest方法的具体用法?PHP IContextSource::setRequest怎么用?PHP IContextSource::setRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContextSource
的用法示例。
在下文中一共展示了IContextSource::setRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request
/**
* @param $x null|WebRequest
* @return WebRequest
*/
public function request(WebRequest $x = null)
{
$old = $this->context->getRequest();
$this->context->setRequest($x);
return $old;
}
示例2: performRequest
/**
* Performs the request.
* - bad titles
* - read restriction
* - local interwiki redirects
* - redirect loop
* - special pages
* - normal pages
*
* @throws MWException|PermissionsError|BadTitleError|HttpError
* @return void
*/
private function performRequest()
{
global $wgTitle;
$request = $this->context->getRequest();
$requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
if ($request->getVal('printable') === 'yes') {
$output->setPrintable();
}
$unused = null;
// To pass it by reference
Hooks::run('BeforeInitialize', [&$title, &$unused, &$output, &$user, $request, $this]);
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && !$title->isExternal() || $title->isSpecial('Badtitle')) {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
try {
$this->parseTitle();
} catch (MalformedTitleException $ex) {
throw new BadTitleError($ex);
}
throw new BadTitleError();
}
// Check user's permissions to read this page.
// We have to check here to catch special pages etc.
// We will check again in Article::view().
$permErrors = $title->isSpecial('RunJobs') ? [] : $title->getUserPermissionsErrors('read', $user);
if (count($permErrors)) {
// Bug 32276: allowing the skin to generate output with $wgTitle or
// $this->context->title set to the input title would allow anonymous users to
// determine whether a page exists, potentially leaking private data. In fact, the
// curid and oldid request parameters would allow page titles to be enumerated even
// when they are not guessable. So we reset the title to Special:Badtitle before the
// permissions error is displayed.
// The skin mostly uses $this->context->getTitle() these days, but some extensions
// still use $wgTitle.
$badTitle = SpecialPage::getTitleFor('Badtitle');
$this->context->setTitle($badTitle);
$wgTitle = $badTitle;
throw new PermissionsError('read', $permErrors);
}
// Interwiki redirects
if ($title->isExternal()) {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL(['rdfrom' => $rdfrom]);
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
// Check for a redirect loop
if (!preg_match('/^' . preg_quote($this->config->get('Server'), '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$this->context->setTitle(SpecialPage::getTitleFor('Badtitle'));
try {
$this->parseTitle();
} catch (MalformedTitleException $ex) {
throw new BadTitleError($ex);
}
throw new BadTitleError();
}
// Handle any other redirects.
// Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif (!$this->tryNormaliseRedirect($title)) {
// Prevent information leak via Special:MyPage et al (T109724)
if ($title->isSpecialPage()) {
$specialPage = SpecialPageFactory::getPage($title->getDBkey());
if ($specialPage instanceof RedirectSpecialPage) {
$specialPage->setContext($this->context);
if ($this->config->get('HideIdentifiableRedirects') && $specialPage->personallyIdentifiableTarget()) {
list(, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
$target = $specialPage->getRedirect($subpage);
// target can also be true. We let that case fall through to normal processing.
if ($target instanceof Title) {
$query = $specialPage->getRedirectQuery() ?: [];
$request = new DerivativeRequest($this->context->getRequest(), $query);
$request->setRequestURL($this->context->getRequest()->getRequestURL());
$this->context->setRequest($request);
// Do not varnish cache these. May vary even for anons
$this->context->getOutput()->lowerCdnMaxage(0);
$this->context->setTitle($target);
$wgTitle = $target;
// Reset action type cache. (Special pages have only view)
$this->action = null;
$title = $target;
//.........这里部分代码省略.........