Exemplo n.º 1
0
 /**
  * @param SpecialPage $page The special page to execute
  * @param string $subPage The subpage parameter to call the page with
  * @param WebRequest|null $request Web request that may contain URL parameters, etc
  * @param Language|string|null $language The language which should be used in the context
  * @param User|null $user The user which should be used in the context of this special page
  *
  * @throws Exception
  * @return array( string, WebResponse ) A two-elements array containing the HTML output
  * generated by the special page as well as the response object.
  */
 public function executeSpecialPage(SpecialPage $page, $subPage = '', WebRequest $request = null, $language = null, User $user = null)
 {
     $context = $this->newContext($request, $language, $user);
     $output = new OutputPage($context);
     $context->setOutput($output);
     $page->setContext($context);
     $output->setTitle($page->getPageTitle());
     $html = $this->getHTMLFromSpecialPage($page, $subPage);
     $response = $context->getRequest()->response();
     if ($response instanceof FauxResponse) {
         $code = $response->getStatusCode();
         if ($code > 0) {
             $response->header('Status: ' . $code . ' ' . HttpStatus::getMessage($code));
         }
     }
     return [$html, $response];
 }