Nextcloud PHP API (master)

IURLGenerator

Class to generate URLs

Tags
since
6.0.0
Attributes
#[Consumable]
$since: '6.0.0'

Table of Contents

Constants

URL_REGEX  : mixed = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi'
Regex for matching http(s) urls
URL_REGEX_NO_MODIFIERS  : mixed = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+...
Regex for matching http(s) urls (without modifiers for client compatibility)

Methods

getAbsoluteURL()  : non-empty-string
Makes a URL absolute
getBaseUrl()  : non-empty-string
getLogoutUrl()  : non-empty-string
Return the url to the logout action.
getWebroot()  : string
imagePath()  : string
Returns the link to an image, like linkTo but only with prepending img/
linkTo()  : string
Returns a URL for an image or file
linkToDefaultPageUrl()  : string
Returns the URL of the default page based on the system configuration and the apps visible for the current user
linkToDocs()  : string
linkToOCSRouteAbsolute()  : string
linkToRemote()  : string
Return the url to the remote DAV handler.
linkToRoute()  : string
Returns the URL for a route
linkToRouteAbsolute()  : non-empty-string
Returns the absolute URL for a route

Constants

URL_REGEX

Regex for matching http(s) urls

public mixed URL_REGEX = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi'

This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing

Tags
since
25.0.0
29.0.0

changed to match localhost and hostnames with ports

URL_REGEX_NO_MODIFIERS

Regex for matching http(s) urls (without modifiers for client compatibility)

public mixed URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)'

This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing

Tags
since
25.0.0
29.0.0

changed to match localhost and hostnames with ports

Methods

getAbsoluteURL()

Makes a URL absolute

public getAbsoluteURL(string $url) : non-empty-string
Parameters
$url : string

the url in the ownCloud host

Tags
since
6.0.0
Return values
non-empty-string —

the absolute version of the url

getBaseUrl()

public getBaseUrl() : non-empty-string
Tags
since
13.0.0
Return values
non-empty-string —

base url of the current request

getLogoutUrl()

Return the url to the logout action.

public getLogoutUrl() : non-empty-string
Tags
since
35.0.0
Return values
non-empty-string

getWebroot()

public getWebroot() : string
Tags
since
23.0.0
Return values
string —

webroot part of the base url

imagePath()

Returns the link to an image, like linkTo but only with prepending img/

public imagePath(string $appName, string $file) : string
Parameters
$appName : string

the name of the app

$file : string

the name of the file

Tags
throws
RuntimeException

If the image does not exist

since
6.0.0
Return values
string —

the url

linkTo()

Returns a URL for an image or file

public linkTo(string $appName, string $file[, array<string|int, mixed> $args = [] ]) : string
Parameters
$appName : string

the name of the app

$file : string

the name of the file

$args : array<string|int, mixed> = []

array with param=>value, will be appended to the returned url The value of $args will be urlencoded

Tags
since
6.0.0
Return values
string —

the url

linkToDefaultPageUrl()

Returns the URL of the default page based on the system configuration and the apps visible for the current user

public linkToDefaultPageUrl() : string
Tags
since
23.0.0
Return values
string

linkToDocs()

public linkToDocs(string $key) : string
Parameters
$key : string
Tags
since
8.0.0
Return values
string —

url to the online documentation

linkToOCSRouteAbsolute()

public linkToOCSRouteAbsolute(string $routeName[, array<string|int, mixed> $arguments = [] ]) : string
Parameters
$routeName : string
$arguments : array<string|int, mixed> = []
Tags
since
15.0.0
Return values
string

linkToRemote()

Return the url to the remote DAV handler.

public linkToRemote(string $service) : string
Parameters
$service : string
Tags
since
34.0.0
Return values
string

linkToRoute()

Returns the URL for a route

public linkToRoute(non-empty-string $routeName[, array<string|int, mixed> $arguments = [] ]) : string
Parameters
$routeName : non-empty-string

the name of the route

$arguments : array<string|int, mixed> = []

an array with arguments which will be filled into the url

Tags
since
6.0.0
Return values
string —

the url

linkToRouteAbsolute()

Returns the absolute URL for a route

public linkToRouteAbsolute(non-empty-string $routeName[, array<string|int, mixed> $arguments = [] ]) : non-empty-string
Parameters
$routeName : non-empty-string

the name of the route

$arguments : array<string|int, mixed> = []

an array with arguments which will be filled into the url

Tags
since
8.0.0
Return values
non-empty-string —

the absolute url

On this page

Search results