From bc62b9c17577ffdaccce530d2a1753ae7af03930 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 18 Nov 2015 11:06:37 +0100 Subject: [PATCH] Updated LinkHandler to use DI --- .../application/ApplicationHandler.class.php | 1 + .../lib/system/request/LinkHandler.class.php | 46 +++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php index b0043f54ea..a949d56d03 100644 --- a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php +++ b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php @@ -1,5 +1,6 @@ applicationHandler = $applicationHandler; + $this->requestHandler = $requestHandler; + $this->routeHandler = $routeHandler; + + parent::__construct(); + } + /** * @see \wcf\system\SingletonFactory::init() */ @@ -65,7 +95,7 @@ class LinkHandler extends SingletonFactory { public function getLink($controller = null, array $parameters = array(), $url = '') { $abbreviation = 'wcf'; $anchor = ''; - $isACP = $originIsACP = RequestHandler::getInstance()->isACPRequest(); + $isACP = $originIsACP = $this->requestHandler->isACPRequest(); $forceWCF = $isRaw = false; $appendSession = $encodeTitle = true; @@ -127,7 +157,7 @@ class LinkHandler extends SingletonFactory { $controller = 'Index'; } else { - return PageMenu::getInstance()->getLandingPage()->getProcessor()->getLink(); + return WCF::getDIContainer()->get(PageMenu::class)->getLandingPage()->getProcessor()->getLink(); } } @@ -162,7 +192,7 @@ class LinkHandler extends SingletonFactory { } $parameters['controller'] = $controller; - $routeURL = RouteHandler::getInstance()->buildRoute($parameters, $isACP); + $routeURL = $this->routeHandler->buildRoute($parameters, $isACP); if (!$isRaw && !empty($url)) { $routeURL .= (strpos($routeURL, '?') === false) ? '?' : '&'; } @@ -184,22 +214,22 @@ class LinkHandler extends SingletonFactory { $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url; } else { - if (RequestHandler::getInstance()->inRescueMode()) { + if ($this->requestHandler->inRescueMode()) { $pageURL = RouteHandler::getHost() . str_replace('//', '/', RouteHandler::getPath(array('acp'))); } else { // try to resolve abbreviation $application = null; if ($abbreviation != 'wcf') { - $application = ApplicationHandler::getInstance()->getApplication($abbreviation); + $application = $this->applicationHandler->getApplication($abbreviation); } // fallback to primary application if abbreviation is 'wcf' or unknown if ($forceWCF) { - $application = ApplicationHandler::getInstance()->getWCF(); + $application = $this->applicationHandler->getWCF(); } else if ($application === null) { - $application = ApplicationHandler::getInstance()->getPrimaryApplication(); + $application = $this->applicationHandler->getPrimaryApplication(); } $pageURL = $application->getPageURL(); -- 2.20.1