diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index a34333d..f4efbdf 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -88,20 +88,6 @@ class Url { const SCHEME_BASE = 'base'; /** - * Scheme for URIs from user input. - * - * To create a URL for paths from user input that may or may not correspond - * to a valid Drupal route, use Url::fromUserInput(). - * - * @see \Drupal\Core\Url::fromUserInput() - * @see \Drupal\Core\Url::fromUserPathUri() - * - * @todo Rename this constant depending on the outcome of: - * https://www.drupal.org/node/2417567 - */ - const SCHEME_USER_PATH = 'user-path'; - - /** * Scheme for entity URIs. * * This scheme should be used for entity URIs, which are given in the form @@ -384,37 +370,6 @@ protected static function trimLeadingSlashes($path) { } /** - * Creates a Url object for a path from user input. - * - * Use this method to create a URL for paths from user input that may or may - * not correspond to a valid Drupal route. - * - * @param string $path - * A path string from user input. Only three types of paths are allowed: - * - Site paths, beginning with a '/'. - * - Query strings, beginning with a '?'. - * - Fragments, beginning with a '#'. - * @param array $options - * (optional) An array of options. See Url::fromUri() for details. - * - * @return static - * A new Url object based on user input. - * - * @todo The intent here is to support a user interaction pattern where - * entering one of the three allowed characters at the beginning of a - * field denotes that the user wants to link to a specific path on the - * site, with all other input interpreted as an attempt to autocomplete the - * label of a specific resource. How do we document that, and how do we - * establish the expectation for other APIs and for UIs? - */ - public static function fromUserInput($path, $options = []) { - if ((strpos($path, '/') !== 0) && (strpos($path, '/') !== 0) && (strpos($path, '/') !== 0)) { - throw new \InvalidArgumentException(String::format('The path @path is not valid as user input. User-input paths must begin with one of the following characters: / # ?', ['@path' => $path])); - } - return static::fromUri(static::SCHEME_USER_PATH . ':' . $path, $options); - } - - /** * Creates a new Url object from a URI. * * This method is used to create URLs for internal and external URIs with a @@ -499,7 +454,7 @@ public static function fromUri($uri, $options = []) { if ($uri_parts['scheme'] === static::SCHEME_ENTITY) { $url = static::fromEntityUri($uri_parts, $uri_options, $uri); } - elseif ($uri_parts['scheme'] === static::SCHEME_USER_PATH) { + elseif ($uri_parts['scheme'] === 'user-path') { $url = static::fromUserPathUri($uri_parts, $uri_options); } elseif ($uri_parts['scheme'] === static::SCHEME_ROUTE) { @@ -577,13 +532,10 @@ protected static function fromEntityUri(array $uri_parts, array $options, $uri) * @param array $uri_parts * Parts from an URI of the form user-path:{path} as from parse_url(). * @param array $options - * An array of options. See Url::fromUri() for details. + * An array of options, see static::fromUri() for details. * - * @return static + * @return \Drupal\Core\Url * A new Url object for a 'user-path:' URI. - * - * @todo Rename this method depending on the outcome of: - * https://www.drupal.org/node/2417567 */ protected static function fromUserPathUri(array $uri_parts, array $options) { // Both PathValidator::getUrlIfValidWithoutAccessCheck() and 'base:' URIs