Commit 1dee6b7b authored by jhodgdon's avatar jhodgdon
Browse files

Issue #2277623 by mparker17: Update url parse documentation

parent f4ce0188
...@@ -112,30 +112,30 @@ public static function filterQueryParameters(array $query, array $exclude = arra ...@@ -112,30 +112,30 @@ public static function filterQueryParameters(array $query, array $exclude = arra
} }
/** /**
* Parses a system URL string into an associative array. * Parses a URL string into its path, query, and fragment components.
* *
* This function should only be used for URLs that have been generated by the * This function splits both internal paths like @code node?b=c#d @endcode and
* system. It should not be used for URLs that come from external sources, or * external URLs like @code https://example.com/a?b=c#d @endcode into their
* URLs that link to external resources. * component parts. See
* @link http://tools.ietf.org/html/rfc3986#section-3 RFC 3986 @endlink for an
* explanation of what the component parts are.
* *
* The returned array contains a 'path' that may be passed separately to url(). * Note that, unlike the RFC, when passed an external URL, this function
* For example: * groups the scheme, authority, and path together into the path component.
* @code
* $options = UrlHelper::parse(\Drupal::request()->query->get('destination'));
* $my_url = url($options['path'], $options);
* $my_link = l('Example link', $options['path'], $options);
* @endcode
* *
* @param string $url * @param string $url
* The URL string to parse, i.e. * The internal path or external URL string to parse.
* \Drupal::request()->query->get('destination').
* *
* @return * @return array
* An associative array containing the keys: * An associative array containing:
* - 'path': The path of the URL. If the given $url is external, this includes * - path: The path component of $url. If $url is an external URL, this
* the scheme and host. * includes the scheme, authority, and path.
* - 'query': An array of query parameters of $url, if existent. * - query: An array of query parameters from $url, if they exist.
* - 'fragment': The fragment of $url, if existent. * - fragment: The fragment component from $url, if it exists.
*
* @see l()
* @see url()
* @see http://tools.ietf.org/html/rfc3986
* *
* @ingroup php_wrappers * @ingroup php_wrappers
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment