CoolCMS API

SafeLinkExtension extends Extension
in package

FinalYes

Table of Contents

Properties

$loggedFailures  : array<string, true>
Log deduplication within a request: one broken binding gives one log line, not one per menu item.

Methods

createSafeLink()  : string
generateSafeLink()  : string
Builds a link for the macro; public and static so compiled templates can call it.
getFunctions()  : array<string|int, mixed>
logFailure()  : void
Logs the failure to `log/warning.log`, deduplicated to one line per destination and request. A silent failure would hide bad data; the render is not interrupted.
presenterExists()  : bool

Properties

$loggedFailures

Log deduplication within a request: one broken binding gives one log line, not one per menu item.

private static array<string, true> $loggedFailures = []

Methods

public createSafeLink(Template $template, string $destination[, array<string, mixed> $params = [] ]) : string
Parameters
$template : Template
$destination : string
$params : array<string, mixed> = []
Return values
string

Builds a link for the macro; public and static so compiled templates can call it.

public static generateSafeLink(Presenter|null $presenter, string $destination[, array<string, mixed> $params = [] ]) : string

Contract: never throws and never breaks the render. A link that cannot be built gives '#', in production and debug mode alike.

IMPORTANT: Presenter::link() does not propagate InvalidLinkException itself. It hands it to Presenter::handleInvalidLink(), which per invalidLinkMode (in a debug build InvalidLinkWarning) turns it into E_USER_WARNING. config/Shared/tracy.neon enables strictMode for everything except deprecations, so Tracy turns the warning into a bluescreen and exit(255) in the middle of the render, and the catch (\Throwable) below never runs because a warning is not an exception. One broken page-route binding in cms_system_page_route_rel would then kill every page on a dev server while production silently returned '#' and hid the bad data.

Therefore InvalidLinkException is forced for the duration of the call (an exception can be caught) and the original mode is restored in finally.

Parameters
$presenter : Presenter|null
$destination : string
$params : array<string, mixed> = []
Return values
string

getFunctions()

public getFunctions() : array<string|int, mixed>
Return values
array<string|int, mixed>

logFailure()

Logs the failure to `log/warning.log`, deduplicated to one line per destination and request. A silent failure would hide bad data; the render is not interrupted.

private static logFailure(string $destination, Throwable $e) : void
Parameters
$destination : string
$e : Throwable

presenterExists()

private static presenterExists(string $destination) : bool
Parameters
$destination : string
Return values
bool
On this page

Search results