Documentation

setRouteHandler

void public static
\Bitrix\Main\UrlPreview\Router::setRouteHandler(
 string $route,
 string $handlerModule,
 string $handlerClass,
 array $handlerParameters
);

Static method adds or when route exists, update route handling method.

Parameters

ParameterDescriptionVersion
$routeURL route template. Route parameters must be enclosed into hash marks, for example: /user/#userId#/.
$handlerModuleRoute handler module.
$handlerClassRoute handler class must use the following methods:
  • buildPreview($params): string Method must accept array with parameters and return finished rich link.
  • checkUserReadAccess($params): boolean. Method must accept array with parameters and return true, when registered user has successfully read the entity and returns false otherwise.
  • getCacheTag(): string. Method must return cache tag for entity.
$handlerParametersArray with parameters sent by the method into handler. Array must be passed as argument when calling handler method for creating a rich link or checking access permissions. Array with values must contain variables, referencing to route parameters, for example: ['userId' => '$userId'].

Exceptions

Example



© «Bitrix24», 2001-2024