Nextcloud PHP API (master)

IURLGenerator

Class to generate URLs

Tags
since
6.0.0

Table of Contents

Constants

URL_REGEX  = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi'
Regex for matching http(s) urls
URL_REGEX_NO_MODIFIERS  = '(\\s|\\n|^)(https?:\\/\\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\\s|\\n|$)'
Regex for matching http(s) urls (without modifiers for client compatibility)

Methods

getAbsoluteURL()  : string
Makes an URL absolute
getBaseUrl()  : string
getWebroot()  : string
imagePath()  : string
Returns the link to an image, like linkTo but only with prepending img/
linkTo()  : string
Returns an 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
linkToRoute()  : string
Returns the URL for a route
linkToRouteAbsolute()  : 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
since
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
since
29.0.0

changed to match localhost and hostnames with ports

Methods

getAbsoluteURL()

Makes an URL absolute

public getAbsoluteURL(string $url) : string
Parameters
$url : string

the url in the ownCloud host

Tags
since
6.0.0
Return values
string

the absolute version of the url

getBaseUrl()

public getBaseUrl() : string
Tags
since
13.0.0
Return values
string

base url of the current request

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 an 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

linkToRoute()

Returns the URL for a route

public linkToRoute(string $routeName[, array<string|int, mixed> $arguments = [] ]) : string
Parameters
$routeName : 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(string $routeName[, array<string|int, mixed> $arguments = [] ]) : string
Parameters
$routeName : 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
string

the absolute url


        
On this page

Search results