Upgrade to 3.0.1

This commit is contained in:
Bastian Allgeier
2019-02-05 11:26:42 +01:00
parent 1dc0eeb768
commit f76ee1bb14
39 changed files with 4217 additions and 65 deletions

View File

@@ -47,15 +47,33 @@ class Url extends BaseUrl
* Smart resolver for internal and external urls
*
* @param string $path
* @param array $options
* @param array|string|null $options Either an array of options for the Uri class or a language string
* @return string
*/
public static function to(string $path = null, array $options = null): string
public static function to(string $path = null, $options = null): string
{
$kirby = App::instance();
$kirby = App::instance();
$language = null;
// get language from simple string option
if (is_string($options) === true) {
$language = $options;
$options = null;
}
// get language from array
if (is_array($options) === true && isset($options['language']) === true) {
$language = $options['language'];
unset($options['language']);
}
// get a language url for the linked page, if the page can be found
if ($language !== null && $kirby->multilang() === true && $page = page($path)) {
$path = $page->url($language);
}
if ($handler = $kirby->component('url')) {
return $handler($kirby, $path, $options, function (string $path = null, array $options = null) {
return $handler($kirby, $path, $options, function (string $path = null, $options = null) {
return parent::to($path, $options);
});
}