From: Alexander Ebert Date: Wed, 8 Jun 2016 10:18:28 +0000 (+0200) Subject: Added proper support for CI controllers X-Git-Tag: 3.0.0_Beta_1~1489 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=578513198ff9daf726135aeda85eb8c94342aaa3;p=GitHub%2FWoltLab%2FWCF.git Added proper support for CI controllers --- diff --git a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php index eb2d185586..87a2f54a6f 100644 --- a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php +++ b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php @@ -66,15 +66,19 @@ class ControllerMap extends SingletonFactory { throw new SystemException("Malformed controller name '" . $controller . "'"); } - $parts = explode('-', $controller); - $parts = array_map('ucfirst', $parts); - $controller = implode('', $parts); - - if ($controller === 'AjaxProxy') $controller = 'AJAXProxy'; - - $classData = $this->getClassData($application, $controller, $isAcpRequest, 'page'); - if ($classData === null) $classData = $this->getClassData($application, $controller, $isAcpRequest, 'form'); - if ($classData === null) $classData = $this->getClassData($application, $controller, $isAcpRequest, 'action'); + $classData = $this->getLegacyClassData($application, $controller, $isAcpRequest); + if ($classData === null) { + $parts = explode('-', $controller); + $parts = array_map('ucfirst', $parts); + $controller = implode('', $parts); + + // work-around for upgrade path 2.1 -> 2.2 + if ($controller === 'AjaxProxy') $controller = 'AJAXProxy'; + + $classData = $this->getClassData($application, $controller, $isAcpRequest, 'page'); + if ($classData === null) $classData = $this->getClassData($application, $controller, $isAcpRequest, 'form'); + if ($classData === null) $classData = $this->getClassData($application, $controller, $isAcpRequest, 'action'); + } if ($classData === null) { throw new SystemException("Unknown controller '" . $controller . "'"); @@ -269,6 +273,32 @@ class ControllerMap extends SingletonFactory { return true; } + /** + * Lookups the list of legacy controller names that violate the name + * schema, e.g. are named 'BBCodeList' instead of `BbCodeList`. + * + * @param string $application application identifier + * @param string $controller controller name + * @param boolean $isAcpRequest true if this is an ACP request + * @return string[]|null className, controller and pageType, or null if this is not a legacy controller name + */ + protected function getLegacyClassData($application, $controller, $isAcpRequest) { + $environment = ($isAcpRequest) ? 'acp' : 'frontend'; + if (isset($this->ciControllers['lookup'][$application][$environment][$controller])) { + $className = $this->ciControllers['lookup'][$application][$environment][$controller]; + + if (preg_match('~\\\\(?P[^\\\\]+)(?PAction|Form|Page)$~', $className, $matches)) { + return [ + 'className' => $className, + 'controller' => $matches['controller'], + 'pageType' => strtolower($matches['pageType']) + ]; + } + } + + return null; + } + /** * Returns the class data for the active request or null if for the given * configuration no proper class exist.