Bitrix API

Router

Table of Contents

Constants

CACHE_ID  = 'UrlPreviewRouteCache'
CACHE_TTL  = 315360000

Methods

dispatch()  : array<string|int, mixed>|false
Returns handler for the url
invalidateRouteCache()  : void
Resets router cache
setRouteHandler()  : void
Adds, or, if route already exists, changes route handling method.

Constants

CACHE_ID

public mixed CACHE_ID = 'UrlPreviewRouteCache'

CACHE_TTL

public mixed CACHE_TTL = 315360000

Methods

dispatch()

Returns handler for the url

public static dispatch(Uri $uri) : array<string|int, mixed>|false
Parameters
$uri : Uri

Absolute or relative URL.

Return values
array<string|int, mixed>|false

Handler for this URL if found, false otherwise.

invalidateRouteCache()

Resets router cache

public static invalidateRouteCache() : void

setRouteHandler()

Adds, or, if route already exists, changes route handling method.

public static setRouteHandler(string $route, string $handlerModule, string $handlerClass, array<string|int, mixed> $handlerParameters) : void
Parameters
$route : string

Route URL template. Route parameters should be enclosed in hash symbols, like '/user/#userId#/'.

$handlerModule : string

Route handler module.

$handlerClass : string

Route handler class should implement methods:

  • buildPreview($params): string. Method must accept array of parameters and return rendered preview
  • checkUserReadAccess($params): boolean. Method must accept array of parameters. Method must return true if currently logged in user has read access to the entity; false otherwise.
  • getCacheTag(): string. Method must return cache tag for the entity.
.
$handlerParameters : array<string|int, mixed>

Array of parameters, passed to the handler methods. Will be passed as the argument when calling handler's method for building preview or checking access. Array values may contain variables referencing route parameters. e.g. ['userId' => '$userId'].

Tags
throws
ArgumentException

        
On this page

Search results