From: Alexander Ebert Date: Thu, 8 Sep 2016 18:37:19 +0000 (+0200) Subject: Improved static routes X-Git-Tag: 3.0.0_Beta_1~255 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=45762819304dc6ebd8677dddb7233ee0c942f0be;p=GitHub%2FWoltLab%2FWCF.git Improved static routes --- diff --git a/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php b/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php index 532ed04ef4..62ee842cb3 100644 --- a/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/route/StaticRequestRoute.class.php @@ -12,6 +12,12 @@ use wcf\system\request\ControllerMap; * @since 3.0 */ class StaticRequestRoute extends DynamicRequestRoute { + /** + * controller must be present and match the static controller + * @var boolean + */ + protected $matchController = false; + /** * static application identifier * @var string @@ -32,6 +38,16 @@ class StaticRequestRoute extends DynamicRequestRoute { parent::setIsACP(false); } + /** + * Controller must be part of the url and match the static controller, useful + * for controllers requiring a custom set of additional parameters. + * + * @param boolean $matchController + */ + public function setMatchController($matchController) { + $this->matchController = $matchController; + } + /** * Sets the static controller for this route. * @@ -49,6 +65,10 @@ class StaticRequestRoute extends DynamicRequestRoute { * @inheritDoc */ public function buildLink(array $components) { + if ($this->matchController) { + return parent::buildLink($components); + } + // static routes don't have these components unset($components['application']); unset($components['controller']); @@ -74,8 +94,13 @@ class StaticRequestRoute extends DynamicRequestRoute { */ public function matches($requestURL) { if (parent::matches($requestURL)) { + $controller = ControllerMap::getInstance()->lookup($this->staticApplication, $this->staticController); + if ($this->matchController && $this->routeData['controller'] !== $controller) { + return false; + } + $this->routeData['application'] = $this->staticApplication; - $this->routeData['controller'] = ControllerMap::getInstance()->lookup($this->staticApplication, $this->staticController); + $this->routeData['controller'] = $controller; $this->routeData['isDefaultController'] = false; return true;