* @since 3.0
*/
class RoutingCacheBuilder extends AbstractCacheBuilder {
+ /**
+ * list of controllers violating the url schema, but are
+ * supported for legacy reasons
+ * @var array
+ */
+ protected $brokenControllers = [
+ 'lookup' => [],
+ 'reverse' => []
+ ];
+
/**
* @inheritDoc
*/
// drop the last part containing `Action` or `Page`
array_pop($parts);
+ // fix for invalid pages that would cause single character fragments
+ $sanitizedParts = [];
+ $tmp = '';
+ $isBrokenController = false;
+ foreach ($parts as $part) {
+ if (strlen($part) === 1) {
+ $isBrokenController = true;
+ $tmp .= $part;
+ continue;
+ }
+
+ $sanitizedParts[] = $tmp . $part;
+ $tmp = '';
+ }
+ if ($tmp) $sanitizedParts[] = $tmp;
+ $parts = $sanitizedParts;
+
$ciController = implode('-', array_map('strtolower', $parts));
$className = $abbreviation . '\\' . ($libDirectory === 'lib/acp' ? 'acp\\' : '') . $pageType . '\\' . $filename;
if (!isset($data['lookup'][$abbreviation])) $data['lookup'][$abbreviation] = ['acp' => [], 'frontend' => []];
$data['lookup'][$abbreviation][$libDirectory === 'lib' ? 'frontend' : 'acp'][$ciController] = $className;
$data['reverse'][$filename] = $ciController;
+
+ if ($isBrokenController) {
+ if (!isset($this->brokenControllers['lookup'][$abbreviation])) $this->brokenControllers['lookup'][$abbreviation] = [];
+ $this->brokenControllers['lookup'][$abbreviation][$ciController] = $className;
+
+ if (!isset($this->brokenControllers['reverse'][$abbreviation])) $this->brokenControllers['reverse'][$abbreviation] = [];
+ $this->brokenControllers['reverse'][$abbreviation][preg_replace('~(?:Page|Form|Action)$~', '', $filename)] = $ciController;
+ }
}
}
}
}
}
+ // masquerade broken controllers as custom urls
+ foreach ($this->brokenControllers as $type => $brokenControllers) {
+ foreach ($brokenControllers as $application => $controllers) {
+ foreach ($controllers as $key => $value) {
+ if (!isset($data[$type][$application])) {
+ $data[$type][$application] = [];
+ }
+
+ if (!isset($data[$type][$application][$key])) {
+ $data[$type][$application][$key] = $value;
+ }
+ }
+ }
+ }
+
return $data;
}