*/ class NamespaceRoute extends AbstractRoute { const OPTION_NAMESPACE = 'namespace'; public function resolve(ServerRequestInterface $request) { $relativeUrl = \tao_helpers_Request::getRelativeUrl($request->getRequestTarget()); $parts = explode('/', $relativeUrl); $slash = strpos($relativeUrl, '/'); if ($slash !== false && substr($relativeUrl, 0, $slash) == $this->getId()) { $config = $this->getConfig(); $namespace = $config[self::OPTION_NAMESPACE]; $rest = substr($relativeUrl, $slash + 1); if (!empty($rest)) { $parts = explode('/', $rest, 3); $controller = rtrim($namespace, '\\') . '\\' . $parts[0]; //todo $method = isset($parts[1]) ? $parts[1] : DEFAULT_ACTION_NAME; return $controller . '@' . $method; } elseif (defined('DEFAULT_MODULE_NAME') && defined('DEFAULT_ACTION_NAME')) { $controller = rtrim($namespace, '\\') . '\\' . DEFAULT_MODULE_NAME; $method = DEFAULT_ACTION_NAME; return $controller . '@' . $method; } } return null; } /** * Get controller namespace prefix * @return string */ public static function getControllerPrefix() { return ''; } }